helper/schema: empty map values should show up in diff [GH-968]
This commit is contained in:
parent
e9778c85a5
commit
5c06cc386a
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue