Skip to content

Commit

Permalink
send scheduling block with automaticrestart if there is none in cfg (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
modular-magician authored and danawillow committed Dec 12, 2018
1 parent 7093102 commit 1663bb8
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions google-beta/resource_compute_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,12 +625,22 @@ func expandComputeInstance(project string, zone *compute.Zone, d *schema.Resourc
disks = append(disks, disk)
}

prefix := "scheduling.0"
scheduling := &computeBeta.Scheduling{
AutomaticRestart: googleapi.Bool(d.Get(prefix + ".automatic_restart").(bool)),
Preemptible: d.Get(prefix + ".preemptible").(bool),
OnHostMaintenance: d.Get(prefix + ".on_host_maintenance").(string),
ForceSendFields: []string{"AutomaticRestart", "Preemptible"},
sch := d.Get("scheduling").([]interface{})
var scheduling *computeBeta.Scheduling
if len(sch) == 0 {
// TF doesn't do anything about defaults inside of nested objects, so if
// scheduling hasn't been set, then send it with its default values.
scheduling = &computeBeta.Scheduling{
AutomaticRestart: googleapi.Bool(true),
}
} else {
prefix := "scheduling.0"
scheduling = &computeBeta.Scheduling{
AutomaticRestart: googleapi.Bool(d.Get(prefix + ".automatic_restart").(bool)),
Preemptible: d.Get(prefix + ".preemptible").(bool),
OnHostMaintenance: d.Get(prefix + ".on_host_maintenance").(string),
ForceSendFields: []string{"AutomaticRestart", "Preemptible"},
}
}

metadata, err := resourceInstanceMetadata(d)
Expand Down

0 comments on commit 1663bb8

Please sign in to comment.