helper/schema: diffing maps that are computed should not result in

change
This commit is contained in:
Mitchell Hashimoto 2014-10-20 14:23:06 -07:00
parent 903aa0250c
commit 39edc5dc04
2 changed files with 26 additions and 0 deletions

View File

@ -580,6 +580,11 @@ func (m schemaMap) diffMap(
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
for k, v := range configMap {
old := stateMap[k]

View File

@ -1191,6 +1191,27 @@ func TestSchemaMap_Diff(t *testing.T) {
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{
"config_vars": &Schema{