mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-04 17:51:11 +00:00
Merge pull request #1779 from danawillow/is-1775
allow setting instance scheduling booleans to false
This commit is contained in:
commit
1fea758265
@ -667,21 +667,13 @@ func expandComputeInstance(project string, zone *compute.Zone, d *schema.Resourc
|
||||
}
|
||||
|
||||
prefix := "scheduling.0"
|
||||
scheduling := &computeBeta.Scheduling{}
|
||||
|
||||
if val, ok := d.GetOk(prefix + ".automatic_restart"); ok {
|
||||
scheduling.AutomaticRestart = googleapi.Bool(val.(bool))
|
||||
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"},
|
||||
}
|
||||
|
||||
if val, ok := d.GetOk(prefix + ".preemptible"); ok {
|
||||
scheduling.Preemptible = val.(bool)
|
||||
}
|
||||
|
||||
if val, ok := d.GetOk(prefix + ".on_host_maintenance"); ok {
|
||||
scheduling.OnHostMaintenance = val.(string)
|
||||
}
|
||||
scheduling.ForceSendFields = []string{"AutomaticRestart", "Preemptible"}
|
||||
|
||||
metadata, err := resourceInstanceMetadata(d)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error creating metadata: %s", err)
|
||||
@ -1069,18 +1061,12 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
|
||||
|
||||
if d.HasChange("scheduling") {
|
||||
prefix := "scheduling.0"
|
||||
scheduling := &compute.Scheduling{}
|
||||
|
||||
if val, ok := d.GetOk(prefix + ".automatic_restart"); ok {
|
||||
scheduling.AutomaticRestart = googleapi.Bool(val.(bool))
|
||||
scheduling := &compute.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"},
|
||||
}
|
||||
if val, ok := d.GetOk(prefix + ".preemptible"); ok {
|
||||
scheduling.Preemptible = val.(bool)
|
||||
}
|
||||
if val, ok := d.GetOk(prefix + ".on_host_maintenance"); ok {
|
||||
scheduling.OnHostMaintenance = val.(string)
|
||||
}
|
||||
scheduling.ForceSendFields = []string{"AutomaticRestart", "Preemptible"}
|
||||
|
||||
op, err := config.clientCompute.Instances.SetScheduling(project,
|
||||
zone, d.Id(), scheduling).Do()
|
||||
|
@ -2339,6 +2339,7 @@ resource "google_compute_instance" "foobar" {
|
||||
}
|
||||
|
||||
scheduling {
|
||||
automatic_restart = false
|
||||
}
|
||||
}
|
||||
`, instance)
|
||||
|
Loading…
Reference in New Issue
Block a user