From df981b234df6eb6d194b7786fb67f4d570581836 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 1 Nov 2016 09:53:53 -0700 Subject: [PATCH] terraform: NewComputed doesn't quit Same logic For #9618, we added the ability to ignore old diffs that were computed and removed (because the ultimate value ended up being the same). This ended up breaking computed list/set logic. The correct behavior, as is evident by how the other "skip" logics work, is to set `ok = true` so that the remainder of the logic can run which handles stuff such as computed lists and sets. --- terraform/diff.go | 2 +- terraform/diff_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/terraform/diff.go b/terraform/diff.go index 488b63b68..5a04f4043 100644 --- a/terraform/diff.go +++ b/terraform/diff.go @@ -615,7 +615,7 @@ func (d *InstanceDiff) Same(d2 *InstanceDiff) (bool, string) { // that value is allowed since it may mean the value ended up // being the same. if diffOld.NewComputed { - continue + ok = true } // No exact match, but maybe this is a set containing computed diff --git a/terraform/diff_test.go b/terraform/diff_test.go index 9f7816f63..fca0fbcbe 100644 --- a/terraform/diff_test.go +++ b/terraform/diff_test.go @@ -608,6 +608,34 @@ func TestInstanceDiffSame(t *testing.T) { "", }, + // NewComputed on set, removed + { + &InstanceDiff{ + Attributes: map[string]*ResourceAttrDiff{ + "foo.#": &ResourceAttrDiff{ + Old: "", + New: "", + NewComputed: true, + }, + }, + }, + &InstanceDiff{ + Attributes: map[string]*ResourceAttrDiff{ + "foo.1": &ResourceAttrDiff{ + Old: "foo", + New: "", + NewRemoved: true, + }, + "foo.2": &ResourceAttrDiff{ + Old: "", + New: "bar", + }, + }, + }, + true, + "", + }, + { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{