Skip to content

Commit

Permalink
Resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aristosvo authored Jul 23, 2020
1 parent 1d6a06c commit 459492a
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions azurerm/internal/services/containers/kubernetes_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -884,24 +884,26 @@ func resourceArmKubernetesClusterUpdate(d *schema.ResourceData, meta interface{}
}

// changing rbacEnabled must still force cluster recreation
if *props.EnableRBAC == rbacEnabled && !*props.AadProfile.Managed {
if *props.EnableRBAC == rbacEnabled {
props.AadProfile = azureADProfile
props.EnableRBAC = utils.Bool(rbacEnabled)

if props.AadProfile.Managed != nil && !*props.AadProfile.Managed {
log.Printf("[DEBUG] Updating the RBAC AAD profile")
future, err := clusterClient.ResetAADProfile(ctx, id.ResourceGroup, id.Name, *props.AadProfile)
if err != nil {
return fmt.Errorf("updating Managed Kubernetes Cluster AAD Profile in cluster %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
}

log.Printf("[DEBUG] Updating the RBAC AAD profile")
future, err := clusterClient.ResetAADProfile(ctx, id.ResourceGroup, id.Name, *props.AadProfile)
if err != nil {
return fmt.Errorf("updating Managed Kubernetes Cluster AAD Profile in cluster %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
}

if err = future.WaitForCompletionRef(ctx, clusterClient.Client); err != nil {
return fmt.Errorf("waiting for update of RBAC AAD profile of Managed Cluster %q (Resource Group %q):, %+v", id.Name, id.ResourceGroup, err)
if err = future.WaitForCompletionRef(ctx, clusterClient.Client); err != nil {
return fmt.Errorf("waiting for update of RBAC AAD profile of Managed Cluster %q (Resource Group %q):, %+v", id.Name, id.ResourceGroup, err)
}
}
} else {
updateCluster = true
}

if *props.AadProfile.Managed {
if props.AadProfile != nil && props.AadProfile.Managed != nil && *props.AadProfile.Managed {
existing.ManagedClusterProperties.AadProfile = azureADProfile
updateCluster = true
}
Expand Down

0 comments on commit 459492a

Please sign in to comment.