1->0 set changes non longer should happen in Read
The new normalization should make preventing those changes unnecessary, and will also prevent extra empty elements from being added when resources are refreshed.
This commit is contained in:
parent
0dc3ca966a
commit
9a39af5047
|
@ -431,7 +431,7 @@ func (s *GRPCProviderServer) ReadResource(_ context.Context, req *proto.ReadReso
|
|||
// here we use the prior state to check for unknown/zero containers values
|
||||
// when normalizing the flatmap.
|
||||
stateAttrs := hcl2shim.FlatmapValueFromHCL2(stateVal)
|
||||
newInstanceState.Attributes = normalizeFlatmapContainers(stateAttrs, newInstanceState.Attributes, true)
|
||||
newInstanceState.Attributes = normalizeFlatmapContainers(stateAttrs, newInstanceState.Attributes, false)
|
||||
}
|
||||
|
||||
if newInstanceState == nil || newInstanceState.ID == "" {
|
||||
|
|
|
@ -709,6 +709,11 @@ func TestNormalizeFlatmapContainers(t *testing.T) {
|
|||
attrs: map[string]string{"map.%": "0", "list.#": "0", "id": "1"},
|
||||
expect: map[string]string{"id": "1", "map.%": "0", "list.#": "0"},
|
||||
},
|
||||
{
|
||||
prior: map[string]string{"list.#": "1", "list.0": "old value"},
|
||||
attrs: map[string]string{"list.#": "0"},
|
||||
expect: map[string]string{},
|
||||
},
|
||||
} {
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
got := normalizeFlatmapContainers(tc.prior, tc.attrs, false)
|
||||
|
|
Loading…
Reference in New Issue