Merge pull request #29849 from hashicorp/kmoe/ignore_changes-override
configs: fix ignore_changes config override bug
This commit is contained in:
commit
ba4b6652fa
|
@ -17,7 +17,7 @@ import (
|
||||||
// diagnostics if any problems are found.
|
// diagnostics if any problems are found.
|
||||||
//
|
//
|
||||||
// This method is "optimistic" in that it will not return errors for possible
|
// 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.
|
// traversal which passed static validation will still fail when evaluated.
|
||||||
func (b *Block) StaticValidateTraversal(traversal hcl.Traversal) tfdiags.Diagnostics {
|
func (b *Block) StaticValidateTraversal(traversal hcl.Traversal) tfdiags.Diagnostics {
|
||||||
if !traversal.IsRelative() {
|
if !traversal.IsRelative() {
|
||||||
|
|
|
@ -242,6 +242,9 @@ func (r *Resource) merge(or *Resource, rps map[string]*RequiredProvider) hcl.Dia
|
||||||
if len(or.Managed.IgnoreChanges) != 0 {
|
if len(or.Managed.IgnoreChanges) != 0 {
|
||||||
r.Managed.IgnoreChanges = or.Managed.IgnoreChanges
|
r.Managed.IgnoreChanges = or.Managed.IgnoreChanges
|
||||||
}
|
}
|
||||||
|
if or.Managed.IgnoreAllChanges {
|
||||||
|
r.Managed.IgnoreAllChanges = true
|
||||||
|
}
|
||||||
if or.Managed.PreventDestroySet {
|
if or.Managed.PreventDestroySet {
|
||||||
r.Managed.PreventDestroy = or.Managed.PreventDestroy
|
r.Managed.PreventDestroy = or.Managed.PreventDestroy
|
||||||
r.Managed.PreventDestroySet = or.Managed.PreventDestroySet
|
r.Managed.PreventDestroySet = or.Managed.PreventDestroySet
|
||||||
|
|
|
@ -320,3 +320,13 @@ func TestModuleOverrideResourceFQNs(t *testing.T) {
|
||||||
t.Fatalf("wrong result: found provider config ref %s, expected nil", got.ProviderConfigRef)
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
resource "test_instance" "foo" {
|
||||||
|
foo = "bar"
|
||||||
|
}
|
6
internal/configs/testdata/valid-modules/override-ignore-changes/main_override.tf
vendored
Normal file
6
internal/configs/testdata/valid-modules/override-ignore-changes/main_override.tf
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
resource "test_instance" "foo" {
|
||||||
|
foo = "bar"
|
||||||
|
lifecycle {
|
||||||
|
ignore_changes = all
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue