Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Feb 27, 2020
1 parent dcf9cfe commit 724e0e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/3178.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
container: Fixed panic when upgrading `google_container_cluster` with autoscaling block
```
9 changes: 7 additions & 2 deletions google/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2196,9 +2196,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 @@ -2210,6 +2213,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
}

return []map[string]interface{}{r}
Expand Down

0 comments on commit 724e0e5

Please sign in to comment.