Skip to content

Commit

Permalink
🐛 Fix nil pointer if no cluster autoscaling (#1766) (#1811)
Browse files Browse the repository at this point in the history
* 🐛 Fix nil pointer if no cluster autoscaling

Related to hashicorp/terraform-provider-google#5685

* 🐛 PR Comments

* 🐛PR comments 2

Co-authored-by: Appréderisse Benjamin <[email protected]>
  • Loading branch information
emilymye and bakayolo authored Mar 2, 2020
1 parent 457e9e1 commit a83262a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions google-beta/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2721,9 +2721,12 @@ func flattenMasterAuth(ma *containerBeta.MasterAuth) []map[string]interface{} {

func flattenClusterAutoscaling(a *containerBeta.ClusterAutoscaling) []map[string]interface{} {
r := make(map[string]interface{})
if a == nil || !a.EnableNodeAutoprovisioning {
if a == nil {
r["enabled"] = false
} else {
return []map[string]interface{}{r}
}

if a.EnableNodeAutoprovisioning {
resourceLimits := make([]interface{}, 0, len(a.ResourceLimits))
for _, rl := range a.ResourceLimits {
resourceLimits = append(resourceLimits, map[string]interface{}{
Expand All @@ -2735,6 +2738,8 @@ func flattenClusterAutoscaling(a *containerBeta.ClusterAutoscaling) []map[string
r["resource_limits"] = resourceLimits
r["enabled"] = true
r["auto_provisioning_defaults"] = flattenAutoProvisioningDefaults(a.AutoprovisioningNodePoolDefaults)
} else {
r["enabled"] = false
}
r["autoscaling_profile"] = a.AutoscalingProfile

Expand Down

0 comments on commit a83262a

Please sign in to comment.