Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
send scheduling block with automaticrestart if there is none in cfg (#…
Browse files Browse the repository at this point in the history
modular-magician authored and paddycarver committed Dec 14, 2018
1 parent 3e806c3 commit 372ba22
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions google/resource_compute_instance.go
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 372ba22

Please sign in to comment.