From 4983befe7ce4c8b8724b57f1057ac2c1fb377b09 Mon Sep 17 00:00:00 2001 From: Dana Hoffman Date: Tue, 11 Dec 2018 23:30:41 +0000 Subject: [PATCH] send scheduling block with automaticrestart if there is none in cfg --- .gometalinter.json | 15 ------------- google/resource_compute_instance.go | 22 ++++++++++++++----- .../docs/r/container_cluster.html.markdown | 4 ++++ 3 files changed, 20 insertions(+), 21 deletions(-) delete mode 100644 .gometalinter.json diff --git a/.gometalinter.json b/.gometalinter.json deleted file mode 100644 index 235b9f58912..00000000000 --- a/.gometalinter.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Deadline": "10m", - "Enable": [ - "vet" - ], - "EnableGC": true, - "Linters": { - }, - "Sort": [ - "path", - "line" - ], - "Vendor": true, - "WarnUnmatchedDirective": true -} diff --git a/google/resource_compute_instance.go b/google/resource_compute_instance.go index 39c6a00550b..7d4ac128646 100644 --- a/google/resource_compute_instance.go +++ b/google/resource_compute_instance.go @@ -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) diff --git a/website/docs/r/container_cluster.html.markdown b/website/docs/r/container_cluster.html.markdown index 07bd79efc32..ed9cc1093eb 100644 --- a/website/docs/r/container_cluster.html.markdown +++ b/website/docs/r/container_cluster.html.markdown @@ -461,6 +461,10 @@ exported: be different than the `min_master_version` set in the config if the master has been updated by GKE. +* `tpu_ipv4_cidr_block` - The IP address range of the Cloud TPUs in this cluster, in + [CIDR](http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) + notation (e.g. `1.2.3.4/29`). + ## Timeouts