Merge pull request #661 from svanharmelen/f-fix-difflist-logic-error
core: fixing a small logic bug in diffList
This commit is contained in:
commit
db640cb1dc
|
@ -459,9 +459,10 @@ func (m schemaMap) diffList(
|
||||||
o, n, _, computedList := d.diffChange(k)
|
o, n, _, computedList := d.diffChange(k)
|
||||||
nSet := n != nil
|
nSet := n != nil
|
||||||
|
|
||||||
// If we have an old value, but no new value set but we're computed,
|
// If we have an old value and no new value is set or will be
|
||||||
// then nothing has changed.
|
// computed once all variables can be interpolated and we're
|
||||||
if o != nil && n == nil && schema.Computed {
|
// computed, then nothing has changed.
|
||||||
|
if o != nil && n == nil && !computedList && schema.Computed {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1466,6 +1466,57 @@ func TestSchemaMap_Diff(t *testing.T) {
|
||||||
|
|
||||||
Err: false,
|
Err: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
Schema: map[string]*Schema{
|
||||||
|
"internal": &Schema{
|
||||||
|
Type: TypeBool,
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
"instances": &Schema{
|
||||||
|
Type: TypeSet,
|
||||||
|
Elem: &Schema{Type: TypeString},
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Set: func(v interface{}) int {
|
||||||
|
return len(v)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
State: &terraform.InstanceState{
|
||||||
|
Attributes: map[string]string{
|
||||||
|
"internal": "false",
|
||||||
|
"instances.#": "0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
Config: map[string]interface{}{
|
||||||
|
"internal": true,
|
||||||
|
"instances": []interface{}{"${var.foo}"},
|
||||||
|
},
|
||||||
|
|
||||||
|
ConfigVariables: map[string]string{
|
||||||
|
"var.foo": config.UnknownVariableValue,
|
||||||
|
},
|
||||||
|
|
||||||
|
Diff: &terraform.InstanceDiff{
|
||||||
|
Attributes: map[string]*terraform.ResourceAttrDiff{
|
||||||
|
"internal": &terraform.ResourceAttrDiff{
|
||||||
|
Old: "0",
|
||||||
|
New: "1",
|
||||||
|
},
|
||||||
|
|
||||||
|
"instances.#": &terraform.ResourceAttrDiff{
|
||||||
|
Old: "0",
|
||||||
|
NewComputed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
Err: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range cases {
|
for i, tc := range cases {
|
||||||
|
|
Loading…
Reference in New Issue