we can normalize nulls in Read again

This should be the final change from removing the flatmap normalization.
Since we're no longer trying to a consistent zero or null value in the
flatmap config, rather we're trying to maintain the previously applied
value, ReadResource also needs to apply the normalizeNullValues step in
order to prevent unexpected diffs.
This commit is contained in:
James Bardin 2019-03-12 16:00:25 -04:00
parent 11ec3a420e
commit 6ecf9b143b
2 changed files with 10 additions and 0 deletions

View File

@ -163,6 +163,15 @@ func testResourceRead(d *schema.ResourceData, meta interface{}) error {
d.Set("computed_map", map[string]string{"key1": "value1"})
d.Set("computed_list", []string{"listval1", "listval2"})
d.Set("computed_set", []string{"setval1", "setval2"})
// if there is no "set" value, erroneously set it to an empty set. This
// might change a null value to an empty set, but we should be able to
// ignore that.
s := d.Get("set")
if s == nil || s.(*schema.Set).Len() == 0 {
d.Set("set", []interface{}{})
}
return nil
}

View File

@ -448,6 +448,7 @@ func (s *GRPCProviderServer) ReadResource(_ context.Context, req *proto.ReadReso
return resp, nil
}
newStateVal = normalizeNullValues(newStateVal, stateVal, false)
newStateVal = copyTimeoutValues(newStateVal, stateVal)
newStateMP, err := msgpack.Marshal(newStateVal, block.ImpliedType())