Skip to content

Commit

Permalink
helper/schema: empty map values should show up in diff [hashicorpGH-968]
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh authored and Yahya Poonawala committed Mar 13, 2015
1 parent 66aeacb commit 73d3f3d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions helper/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,10 @@ func (m schemaMap) diffMap(

// Now we compare, preferring values from the config map
for k, v := range configMap {
old := stateMap[k]
old, ok := stateMap[k]
delete(stateMap, k)

if old == v && !all {
if old == v && ok && !all {
continue
}

Expand Down
32 changes: 32 additions & 0 deletions helper/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2063,6 +2063,38 @@ func TestSchemaMap_Diff(t *testing.T) {

Err: false,
},

// #52 - Map with empty value
{
Schema: map[string]*Schema{
"vars": &Schema{
Type: TypeMap,
},
},

State: nil,

Config: map[string]interface{}{
"vars": map[string]interface{}{
"foo": "",
},
},

Diff: &terraform.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{
"vars.#": &terraform.ResourceAttrDiff{
Old: "0",
New: "1",
},
"vars.foo": &terraform.ResourceAttrDiff{
Old: "",
New: "",
},
},
},

Err: false,
},
}

for i, tc := range cases {
Expand Down

0 comments on commit 73d3f3d

Please sign in to comment.