Skip to content

Commit 07595b8

Browse files
Added nil guard to blue green settings in google_container_node_pool (#7996) (#5671)
Signed-off-by: Modular Magician <[email protected]>
1 parent 115e12e commit 07595b8

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

.changelog/7996.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
container: fixed a crash when all zero values are specified `google_container_node_pool.upgrade_settings.blue_green_settings.standard_rollout_policy` subfields
3+
```

google-beta/resource_container_node_pool.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,13 +1658,14 @@ func nodePoolUpdate(d *schema.ResourceData, meta interface{}, nodePoolInfo *Node
16581658

16591659
if v, ok := blueGreenSettingsConfig["standard_rollout_policy"]; ok && len(v.([]interface{})) > 0 {
16601660
standardRolloutPolicy := &container.StandardRolloutPolicy{}
1661-
standardRolloutPolicyConfig := v.([]interface{})[0].(map[string]interface{})
1662-
standardRolloutPolicy.BatchSoakDuration = standardRolloutPolicyConfig["batch_soak_duration"].(string)
1663-
if v, ok := standardRolloutPolicyConfig["batch_node_count"]; ok {
1664-
standardRolloutPolicy.BatchNodeCount = int64(v.(int))
1665-
}
1666-
if v, ok := standardRolloutPolicyConfig["batch_percentage"]; ok {
1667-
standardRolloutPolicy.BatchPercentage = v.(float64)
1661+
if standardRolloutPolicyConfig, ok := v.([]interface{})[0].(map[string]interface{}); ok {
1662+
standardRolloutPolicy.BatchSoakDuration = standardRolloutPolicyConfig["batch_soak_duration"].(string)
1663+
if v, ok := standardRolloutPolicyConfig["batch_node_count"]; ok {
1664+
standardRolloutPolicy.BatchNodeCount = int64(v.(int))
1665+
}
1666+
if v, ok := standardRolloutPolicyConfig["batch_percentage"]; ok {
1667+
standardRolloutPolicy.BatchPercentage = v.(float64)
1668+
}
16681669
}
16691670
blueGreenSettings.StandardRolloutPolicy = standardRolloutPolicy
16701671
}

0 commit comments

Comments
 (0)