terraform: MergeDiff removes removed attributes in diff
This commit is contained in:
parent
d111a4c05d
commit
cb52983c84
|
@ -247,6 +247,10 @@ func (s *ResourceState) MergeDiff(d *ResourceDiff) *ResourceState {
|
||||||
}
|
}
|
||||||
if d != nil {
|
if d != nil {
|
||||||
for k, diff := range d.Attributes {
|
for k, diff := range d.Attributes {
|
||||||
|
if diff.NewRemoved {
|
||||||
|
delete(result.Attributes, k)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if diff.NewComputed {
|
if diff.NewComputed {
|
||||||
result.Attributes[k] = config.UnknownVariableValue
|
result.Attributes[k] = config.UnknownVariableValue
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -13,6 +13,7 @@ func TestResourceState_MergeDiff(t *testing.T) {
|
||||||
ID: "foo",
|
ID: "foo",
|
||||||
Attributes: map[string]string{
|
Attributes: map[string]string{
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
|
"port": "8000",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +32,9 @@ func TestResourceState_MergeDiff(t *testing.T) {
|
||||||
New: "foo",
|
New: "foo",
|
||||||
NewComputed: true,
|
NewComputed: true,
|
||||||
},
|
},
|
||||||
|
"port": &ResourceAttrDiff{
|
||||||
|
NewRemoved: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue