Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_kubernetes_cluster: pass service_pricipal.client_secret during read #4339

Merged
merged 4 commits into from
Sep 17, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions azurerm/resource_arm_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ func resourceArmKubernetesClusterRead(d *schema.ResourceData, meta interface{})
return fmt.Errorf("Error setting `role_based_access_control`: %+v", err)
}

servicePrincipal := flattenAzureRmKubernetesClusterServicePrincipalProfile(props.ServicePrincipalProfile)
servicePrincipal := flattenAzureRmKubernetesClusterServicePrincipalProfile(props.ServicePrincipalProfile, d)
if err := d.Set("service_principal", servicePrincipal); err != nil {
return fmt.Errorf("Error setting `service_principal`: %+v", err)
}
Expand Down Expand Up @@ -1442,7 +1442,7 @@ func expandAzureRmKubernetesClusterServicePrincipal(d *schema.ResourceData) *con
return &principal
}

func flattenAzureRmKubernetesClusterServicePrincipalProfile(profile *containerservice.ManagedClusterServicePrincipalProfile) []interface{} {
func flattenAzureRmKubernetesClusterServicePrincipalProfile(profile *containerservice.ManagedClusterServicePrincipalProfile, d *schema.ResourceData) []interface{} {
if profile == nil {
return []interface{}{}
}
Expand All @@ -1452,8 +1452,10 @@ func flattenAzureRmKubernetesClusterServicePrincipalProfile(profile *containerse
if clientId := profile.ClientID; clientId != nil {
values["client_id"] = *clientId
}
if secret := profile.Secret; secret != nil {
values["client_secret"] = *secret

// client secret isn't returned by the API so pass the existing value along
if v, ok := d.GetOk("service_principal.0.client_secret"); ok {
values["client_secret"] = v.(string)
}

return []interface{}{values}
Expand Down