helper/schema: detect no change computed for sets/lists properly
This commit is contained in:
parent
eac01c2ac8
commit
9d239eea60
|
@ -287,6 +287,13 @@ func (m schemaMap) diffList(
|
||||||
diff *terraform.ResourceDiff,
|
diff *terraform.ResourceDiff,
|
||||||
d *ResourceData) error {
|
d *ResourceData) error {
|
||||||
o, n, _ := d.diffChange(k)
|
o, n, _ := d.diffChange(k)
|
||||||
|
|
||||||
|
// If we have an old value, but no new value set but we're computed,
|
||||||
|
// then nothing has changed.
|
||||||
|
if o != nil && n == nil && schema.Computed {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if o == nil {
|
if o == nil {
|
||||||
o = []interface{}{}
|
o = []interface{}{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -500,6 +500,32 @@ func TestSchemaMap_Diff(t *testing.T) {
|
||||||
Err: false,
|
Err: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
Schema: map[string]*Schema{
|
||||||
|
"ports": &Schema{
|
||||||
|
Type: TypeSet,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Elem: &Schema{Type: TypeInt},
|
||||||
|
Set: func(v interface{}) int { return v.(int) },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
State: &terraform.ResourceState{
|
||||||
|
Attributes: map[string]string{
|
||||||
|
"availability_zone": "bar",
|
||||||
|
"ports.#": "1",
|
||||||
|
"ports.0": "80",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
Config: map[string]interface{}{},
|
||||||
|
|
||||||
|
Diff: nil,
|
||||||
|
|
||||||
|
Err: false,
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List of structure decode
|
* List of structure decode
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue