Merge pull request #21143 from hashicorp/jbardin/format-sequence-diff
command/format: take noop changes from lcs
This commit is contained in:
commit
54a3e9124e
|
@ -1101,8 +1101,8 @@ func ctySequenceDiff(old, new []cty.Value) []*plans.Change {
|
||||||
if lcsI < len(lcs) {
|
if lcsI < len(lcs) {
|
||||||
ret = append(ret, &plans.Change{
|
ret = append(ret, &plans.Change{
|
||||||
Action: plans.NoOp,
|
Action: plans.NoOp,
|
||||||
Before: new[newI],
|
Before: lcs[lcsI],
|
||||||
After: new[newI],
|
After: lcs[lcsI],
|
||||||
})
|
})
|
||||||
|
|
||||||
// All of our indexes advance together now, since the line
|
// All of our indexes advance together now, since the line
|
||||||
|
|
|
@ -3006,6 +3006,49 @@ func TestResourceChange_nestedMap(t *testing.T) {
|
||||||
- volume_type = "gp2" -> null
|
- volume_type = "gp2" -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
"in-place sequence update - deletion": {
|
||||||
|
Action: plans.Update,
|
||||||
|
Mode: addrs.ManagedResourceMode,
|
||||||
|
Before: cty.ObjectVal(map[string]cty.Value{
|
||||||
|
"list": cty.ListVal([]cty.Value{
|
||||||
|
cty.ObjectVal(map[string]cty.Value{"attr": cty.StringVal("x")}),
|
||||||
|
cty.ObjectVal(map[string]cty.Value{"attr": cty.StringVal("y")}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
After: cty.ObjectVal(map[string]cty.Value{
|
||||||
|
"list": cty.ListVal([]cty.Value{
|
||||||
|
cty.ObjectVal(map[string]cty.Value{"attr": cty.StringVal("y")}),
|
||||||
|
cty.ObjectVal(map[string]cty.Value{"attr": cty.StringVal("z")}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
RequiredReplace: cty.NewPathSet(),
|
||||||
|
Tainted: false,
|
||||||
|
Schema: &configschema.Block{
|
||||||
|
BlockTypes: map[string]*configschema.NestedBlock{
|
||||||
|
"list": {
|
||||||
|
Block: configschema.Block{
|
||||||
|
Attributes: map[string]*configschema.Attribute{
|
||||||
|
"attr": {
|
||||||
|
Type: cty.String,
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Nesting: configschema.NestingList,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ExpectedOutput: ` # test_instance.example will be updated in-place
|
||||||
|
~ resource "test_instance" "example" {
|
||||||
|
~ list {
|
||||||
|
~ attr = "x" -> "y"
|
||||||
|
}
|
||||||
|
~ list {
|
||||||
|
~ attr = "y" -> "z"
|
||||||
|
}
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue