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 {
for k, diff := range d.Attributes {
if diff.NewRemoved {
delete(result.Attributes, k)
continue
}
if diff.NewComputed {
result.Attributes[k] = config.UnknownVariableValue
continue

View File

@ -12,7 +12,8 @@ func TestResourceState_MergeDiff(t *testing.T) {
rs := ResourceState{
ID: "foo",
Attributes: map[string]string{
"foo": "bar",
"foo": "bar",
"port": "8000",
},
}
@ -31,6 +32,9 @@ func TestResourceState_MergeDiff(t *testing.T) {
New: "foo",
NewComputed: true,
},
"port": &ResourceAttrDiff{
NewRemoved: true,
},
},
}