Skip to content

Commit

Permalink
add field maintenance_window.start_time to google_compute_node_group …
Browse files Browse the repository at this point in the history
…(#4656) (#673)

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Apr 5, 2021
1 parent 6d828c1 commit 9448718
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions google/compute_node_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ func GetComputeNodeGroupApiObject(d TerraformResourceData, config *Config) (map[
} else if v, ok := d.GetOkExists("maintenance_policy"); !isEmptyValue(reflect.ValueOf(maintenancePolicyProp)) && (ok || !reflect.DeepEqual(v, maintenancePolicyProp)) {
obj["maintenancePolicy"] = maintenancePolicyProp
}
maintenanceWindowProp, err := expandComputeNodeGroupMaintenanceWindow(d.Get("maintenance_window"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("maintenance_window"); !isEmptyValue(reflect.ValueOf(maintenanceWindowProp)) && (ok || !reflect.DeepEqual(v, maintenanceWindowProp)) {
obj["maintenanceWindow"] = maintenanceWindowProp
}
autoscalingPolicyProp, err := expandComputeNodeGroupAutoscalingPolicy(d.Get("autoscaling_policy"), d, config)
if err != nil {
return nil, err
Expand Down Expand Up @@ -112,6 +118,29 @@ func expandComputeNodeGroupMaintenancePolicy(v interface{}, d TerraformResourceD
return v, nil
}

func expandComputeNodeGroupMaintenanceWindow(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

transformedStartTime, err := expandComputeNodeGroupMaintenanceWindowStartTime(original["start_time"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedStartTime); val.IsValid() && !isEmptyValue(val) {
transformed["startTime"] = transformedStartTime
}

return transformed, nil
}

func expandComputeNodeGroupMaintenanceWindowStartTime(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandComputeNodeGroupAutoscalingPolicy(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down

0 comments on commit 9448718

Please sign in to comment.