terraform: MergeDiff removes removed attributes in diff

This commit is contained in:
Mitchell Hashimoto 2014-07-09 10:04:14 -07:00
parent d111a4c05d
commit cb52983c84
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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,
},
}, },
} }