Skip to content

Commit

Permalink
r/kubernetes_cluster: fixing a null-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Dec 12, 2018
1 parent 6b1b1c8 commit aa8b1f5
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions azurerm/resource_arm_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,25 +986,30 @@ func expandKubernetesClusterRoleBasedAccessControl(input []interface{}, provider
val := input[0].(map[string]interface{})

rbacEnabled := val["enabled"].(bool)

azureADsRaw := val["azure_active_directory"].([]interface{})
azureAdRaw := azureADsRaw[0].(map[string]interface{})

clientAppId := azureAdRaw["client_app_id"].(string)
serverAppId := azureAdRaw["server_app_id"].(string)
serverAppSecret := azureAdRaw["server_app_secret"].(string)
tenantId := azureAdRaw["tenant_id"].(string)
var aad *containerservice.ManagedClusterAADProfile
if len(azureADsRaw) > 0 {
azureAdRaw := azureADsRaw[0].(map[string]interface{})

if tenantId == "" {
tenantId = providerTenantId
}
clientAppId := azureAdRaw["client_app_id"].(string)
serverAppId := azureAdRaw["server_app_id"].(string)
serverAppSecret := azureAdRaw["server_app_secret"].(string)
tenantId := azureAdRaw["tenant_id"].(string)

if tenantId == "" {
tenantId = providerTenantId
}

return rbacEnabled, &containerservice.ManagedClusterAADProfile{
ClientAppID: utils.String(clientAppId),
ServerAppID: utils.String(serverAppId),
ServerAppSecret: utils.String(serverAppSecret),
TenantID: utils.String(tenantId),
aad = &containerservice.ManagedClusterAADProfile{
ClientAppID: utils.String(clientAppId),
ServerAppID: utils.String(serverAppId),
ServerAppSecret: utils.String(serverAppSecret),
TenantID: utils.String(tenantId),
}
}

return rbacEnabled, aad
}

func flattenKubernetesClusterRoleBasedAccessControl(input *containerservice.ManagedClusterProperties, d *schema.ResourceData) []interface{} {
Expand Down

0 comments on commit aa8b1f5

Please sign in to comment.