Skip to content

Commit

Permalink
azurerm_kubernetes_cluster - fix SecurityProfile nilpointer (#20584)
Browse files Browse the repository at this point in the history
  • Loading branch information
aristosvo authored Feb 21, 2023
1 parent b7a0a97 commit 6be7c2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions internal/services/containers/kubernetes_cluster_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ func dataSourceKubernetesClusterRead(d *pluginsdk.ResourceData, meta interface{}
return fmt.Errorf("setting `agent_pool_profile`: %+v", err)
}

azureKeyVaultKms := flattenKubernetesClusterDataSourceKeyVaultKms(props.SecurityProfile.AzureKeyVaultKms)
azureKeyVaultKms := flattenKubernetesClusterDataSourceKeyVaultKms(props.SecurityProfile)
if err := d.Set("key_management_service", azureKeyVaultKms); err != nil {
return fmt.Errorf("setting `key_management_service`: %+v", err)
}
Expand Down Expand Up @@ -849,17 +849,17 @@ func dataSourceKubernetesClusterRead(d *pluginsdk.ResourceData, meta interface{}
return nil
}

func flattenKubernetesClusterDataSourceKeyVaultKms(input *managedclusters.AzureKeyVaultKms) []interface{} {
func flattenKubernetesClusterDataSourceKeyVaultKms(input *managedclusters.ManagedClusterSecurityProfile) []interface{} {
azureKeyVaultKms := make([]interface{}, 0)

if input != nil && input.Enabled != nil && *input.Enabled {
if input != nil && input.AzureKeyVaultKms != nil && input.AzureKeyVaultKms.Enabled != nil && *input.AzureKeyVaultKms.Enabled {
keyId := ""
if v := input.KeyId; v != nil {
if v := input.AzureKeyVaultKms.KeyId; v != nil {
keyId = *v
}

networkAccess := ""
if v := input.KeyVaultNetworkAccess; v != nil {
if v := input.AzureKeyVaultKms.KeyVaultNetworkAccess; v != nil {
networkAccess = string(*v)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2265,7 +2265,7 @@ func resourceKubernetesClusterRead(d *pluginsdk.ResourceData, meta interface{})
}
d.Set("workload_identity_enabled", workloadIdentity)

azureKeyVaultKms := flattenKubernetesClusterDataSourceKeyVaultKms(props.SecurityProfile.AzureKeyVaultKms)
azureKeyVaultKms := flattenKubernetesClusterDataSourceKeyVaultKms(props.SecurityProfile)
if err := d.Set("key_management_service", azureKeyVaultKms); err != nil {
return fmt.Errorf("setting `key_management_service`: %+v", err)
}
Expand Down

0 comments on commit 6be7c2a

Please sign in to comment.