Skip to content

Commit

Permalink
Make it clear that we don't need to ForceSend nested fields in Comput…
Browse files Browse the repository at this point in the history
…eInstanceFromTemplate (#2543)

Merged PR #2543.
  • Loading branch information
danawillow authored and modular-magician committed Oct 25, 2019
1 parent f132365 commit 109ee4f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
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
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 109ee4f

Please sign in to comment.