mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
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,
|
||||
d *ResourceData) error {
|
||||
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 {
|
||||
o = []interface{}{}
|
||||
}
|
||||
|
@ -500,6 +500,32 @@ func TestSchemaMap_Diff(t *testing.T) {
|
||||
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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user