Skip to content

Commit

Permalink
Merge pull request #29849 from hashicorp/kmoe/ignore_changes-override
Browse files Browse the repository at this point in the history
configs: fix ignore_changes config override bug
  • Loading branch information
kmoe committed Nov 1, 2021
2 parents 744a231 + 8e640ae commit ba4b665
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/configs/configschema/validate_traversal.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// diagnostics if any problems are found.
//
// This method is "optimistic" in that it will not return errors for possible
// problems that cannot be detected statically. It is possible that an
// problems that cannot be detected statically. It is possible that a
// traversal which passed static validation will still fail when evaluated.
func (b *Block) StaticValidateTraversal(traversal hcl.Traversal) tfdiags.Diagnostics {
if !traversal.IsRelative() {
Expand Down
3 changes: 3 additions & 0 deletions internal/configs/module_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ func (r *Resource) merge(or *Resource, rps map[string]*RequiredProvider) hcl.Dia
if len(or.Managed.IgnoreChanges) != 0 {
r.Managed.IgnoreChanges = or.Managed.IgnoreChanges
}
if or.Managed.IgnoreAllChanges {
r.Managed.IgnoreAllChanges = true
}
if or.Managed.PreventDestroySet {
r.Managed.PreventDestroy = or.Managed.PreventDestroy
r.Managed.PreventDestroySet = or.Managed.PreventDestroySet
Expand Down
10 changes: 10 additions & 0 deletions internal/configs/module_merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,13 @@ func TestModuleOverrideResourceFQNs(t *testing.T) {
t.Fatalf("wrong result: found provider config ref %s, expected nil", got.ProviderConfigRef)
}
}

func TestModuleOverrideIgnoreAllChanges(t *testing.T) {
mod, diags := testModuleFromDir("testdata/valid-modules/override-ignore-changes")
assertNoDiagnostics(t, diags)

r := mod.ManagedResources["test_instance.foo"]
if !r.Managed.IgnoreAllChanges {
t.Fatalf("wrong result: expected r.Managed.IgnoreAllChanges to be true")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "test_instance" "foo" {
foo = "bar"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "test_instance" "foo" {
foo = "bar"
lifecycle {
ignore_changes = all
}
}

0 comments on commit ba4b665

Please sign in to comment.