Skip to content

Commit 397e688

Browse files
author
Cecile Robert-Michon
committed
Add test for UAMI with private cluster
1 parent efcf8c9 commit 397e688

20 files changed

+87
-509
lines changed

azure/scope/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func NewClusterScope(ctx context.Context, params ClusterScopeParams) (*ClusterSc
8181
}
8282
err = params.AzureClients.setCredentialsWithProvider(ctx, params.AzureCluster.Spec.SubscriptionID, params.AzureCluster.Spec.AzureEnvironment, credentialsProvider)
8383
if err != nil {
84-
return nil, errors.Wrap(err, "FAILED to configure azure settings and credentials for Identity")
84+
return nil, errors.Wrap(err, "failed to configure azure settings and credentials for Identity")
8585
}
8686
}
8787

azure/scope/identity.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ func (p *AzureCredentialsProvider) GetClientID() string {
185185
// NOTE: this only works if the Identity references a Service Principal Client Secret.
186186
// If using another type of credentials, such a Certificate, we return an empty string.
187187
func (p *AzureCredentialsProvider) GetClientSecret(ctx context.Context) (string, error) {
188-
if secretRef := p.Identity.Spec.ClientSecret; secretRef.Name != "" {
188+
if p.hasClientSecret() {
189+
secretRef := p.Identity.Spec.ClientSecret
189190
key := types.NamespacedName{
190191
Namespace: secretRef.Namespace,
191192
Name: secretRef.Name,
@@ -205,6 +206,12 @@ func (p *AzureCredentialsProvider) GetTenantID() string {
205206
return p.Identity.Spec.TenantID
206207
}
207208

209+
// hasClientSecret returns true if the identity has a Service Principal Client Secret.
210+
// This does not include service principals with certificates or managed identities.
211+
func (p *AzureCredentialsProvider) hasClientSecret() bool {
212+
return p.Identity.Spec.Type == infrav1.ServicePrincipal || p.Identity.Spec.Type == infrav1.ManualServicePrincipal
213+
}
214+
208215
func createAzureIdentityWithBindings(ctx context.Context, azureIdentity *infrav1.AzureClusterIdentity, resourceManagerEndpoint, activeDirectoryEndpoint string, clusterMeta metav1.ObjectMeta,
209216
kubeClient client.Client) error {
210217
azureIdentityType, err := getAzureIdentityType(azureIdentity)

templates/cluster-template-system-assigned-identity.yaml

Lines changed: 0 additions & 213 deletions
This file was deleted.

0 commit comments

Comments
 (0)