helper/schema: diffing maps that are computed should not result in
change
This commit is contained in:
parent
903aa0250c
commit
39edc5dc04
|
@ -580,6 +580,11 @@ func (m schemaMap) diffMap(
|
||||||
return fmt.Errorf("%s: %s", k, err)
|
return fmt.Errorf("%s: %s", k, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the new map is nil and we're computed, then ignore it.
|
||||||
|
if n == nil && schema.Computed {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Now we compare, preferring values from the config map
|
// Now we compare, preferring values from the config map
|
||||||
for k, v := range configMap {
|
for k, v := range configMap {
|
||||||
old := stateMap[k]
|
old := stateMap[k]
|
||||||
|
|
|
@ -1191,6 +1191,27 @@ func TestSchemaMap_Diff(t *testing.T) {
|
||||||
Err: false,
|
Err: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
Schema: map[string]*Schema{
|
||||||
|
"vars": &Schema{
|
||||||
|
Type: TypeMap,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
State: &terraform.InstanceState{
|
||||||
|
Attributes: map[string]string{
|
||||||
|
"vars.foo": "bar",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
Config: nil,
|
||||||
|
|
||||||
|
Diff: nil,
|
||||||
|
|
||||||
|
Err: false,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
Schema: map[string]*Schema{
|
Schema: map[string]*Schema{
|
||||||
"config_vars": &Schema{
|
"config_vars": &Schema{
|
||||||
|
|
Loading…
Reference in New Issue