helper/schema: diff of zero value in state with lack of value should not
diff
This commit is contained in:
parent
1752c93e0c
commit
b778a65a83
|
@ -810,6 +810,9 @@ func (m schemaMap) diffString(
|
||||||
originalN = n
|
originalN = n
|
||||||
n = schema.StateFunc(n)
|
n = schema.StateFunc(n)
|
||||||
}
|
}
|
||||||
|
if n == nil {
|
||||||
|
n = schema.Type.Zero()
|
||||||
|
}
|
||||||
if err := mapstructure.WeakDecode(o, &os); err != nil {
|
if err := mapstructure.WeakDecode(o, &os); err != nil {
|
||||||
return fmt.Errorf("%s: %s", k, err)
|
return fmt.Errorf("%s: %s", k, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1943,6 +1943,29 @@ func TestSchemaMap_Diff(t *testing.T) {
|
||||||
Diff: nil,
|
Diff: nil,
|
||||||
Err: false,
|
Err: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// #48
|
||||||
|
{
|
||||||
|
Schema: map[string]*Schema{
|
||||||
|
"port": &Schema{
|
||||||
|
Type: TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
State: &terraform.InstanceState{
|
||||||
|
Attributes: map[string]string{
|
||||||
|
"port": "false",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
Config: map[string]interface{}{},
|
||||||
|
|
||||||
|
Diff: nil,
|
||||||
|
|
||||||
|
Err: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range cases {
|
for i, tc := range cases {
|
||||||
|
|
Loading…
Reference in New Issue