Skip to content

Commit

Permalink
Merge pull request #14 from mjura/master-tenant
Browse files Browse the repository at this point in the history
Move TenantID to Cloud Credentials
  • Loading branch information
mjura authored May 24, 2021
2 parents bad12df + 38079d4 commit 84750d6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions charts/aks-operator-crd/templates/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ spec:
type: string
nullable: true
type: object
tenantId:
nullable: true
type: string
virtualNetwork:
nullable: true
type: string
Expand Down
3 changes: 0 additions & 3 deletions controller/aks-cluster-config-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,6 @@ func (h *Handler) validateConfig(config *aksv1.AKSClusterConfig) error {
if config.Spec.ClusterName == "" {
return fmt.Errorf(cannotBeNilError, "clusterName", config.ClusterName)
}
if config.Spec.TenantID == "" {
return fmt.Errorf(cannotBeNilError, "tenantId", config.ClusterName)
}
if config.Spec.AzureCredentialSecret == "" {
return fmt.Errorf(cannotBeNilError, "azureCredentialSecret", config.ClusterName)
}
Expand Down
6 changes: 5 additions & 1 deletion internal/aks/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ func GetSecrets(secretsCache wranglerv1.SecretCache, spec *aksv1.AKSClusterConfi
return nil, fmt.Errorf("couldn't find secret [%s] in namespace [%s]", id, ns)
}

tenantIDBytes := secret.Data["azurecredentialConfig-tenantId"]
subscriptionIDBytes := secret.Data["azurecredentialConfig-subscriptionId"]
clientIDBytes := secret.Data["azurecredentialConfig-clientId"]
clientSecretBytes := secret.Data["azurecredentialConfig-clientSecret"]

cannotBeNilError := "field [azurecredentialConfig-%s] must be provided in cloud credential"
if tenantIDBytes == nil {
return nil, fmt.Errorf(cannotBeNilError, "tenantId")
}
if subscriptionIDBytes == nil {
return nil, fmt.Errorf(cannotBeNilError, "subscriptionId")
}
Expand All @@ -109,10 +113,10 @@ func GetSecrets(secretsCache wranglerv1.SecretCache, spec *aksv1.AKSClusterConfi
return nil, fmt.Errorf(cannotBeNilError, "clientSecret")
}

cred.TenantID = string(tenantIDBytes)
cred.SubscriptionID = string(subscriptionIDBytes)
cred.ClientID = string(clientIDBytes)
cred.ClientSecret = string(clientSecretBytes)
cred.TenantID = spec.TenantID
cred.AuthBaseURL = spec.AuthBaseURL
cred.BaseURL = spec.BaseURL

Expand Down
1 change: 0 additions & 1 deletion pkg/apis/aks.cattle.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ type AKSClusterConfigSpec struct {
ResourceLocation string `json:"resourceLocation" norman:"noupdate"`
ResourceGroup string `json:"resourceGroup" norman:"noupdate"`
ClusterName string `json:"clusterName" norman:"noupdate"`
TenantID string `json:"tenantId"`
AzureCredentialSecret string `json:"azureCredentialSecret"`
BaseURL *string `json:"baseUrl"`
AuthBaseURL *string `json:"authBaseUrl"`
Expand Down

0 comments on commit 84750d6

Please sign in to comment.