Skip to content

Commit

Permalink
Make it clear that we don't need to ForceSend nested fields in… (#4762)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and danawillow committed Oct 25, 2019
1 parent bfb298f commit 7f460c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 0 additions & 1 deletion google/resource_compute_instance_from_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ func resourceComputeInstanceFromTemplateCreate(d *schema.ResourceData, meta inte
}

// Force send all top-level fields that have been set in case they're overridden to zero values.
// TODO: consider doing so for nested fields as well.
// Initialize ForceSendFields to empty so we don't get things that the instance resource
// always force-sends.
instance.ForceSendFields = []string{}
Expand Down
8 changes: 8 additions & 0 deletions google/resource_compute_instance_from_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func TestAccComputeInstanceFromTemplate_basic(t *testing.T) {
// Check that fields were set based on the template
resource.TestCheckResourceAttr(resourceName, "machine_type", "n1-standard-1"),
resource.TestCheckResourceAttr(resourceName, "attached_disk.#", "1"),
resource.TestCheckResourceAttr(resourceName, "scheduling.0.automatic_restart", "false"),
),
},
},
Expand Down Expand Up @@ -255,6 +256,10 @@ resource "google_compute_instance_template" "foobar" {
foo = "bar"
}
scheduling {
automatic_restart = true
}
can_ip_forward = true
}
Expand All @@ -269,6 +274,9 @@ resource "google_compute_instance_from_template" "foobar" {
labels = {
my_key = "my_value"
}
scheduling {
automatic_restart = false
}
}
`, template, template, instance)
}
Expand Down

0 comments on commit 7f460c8

Please sign in to comment.