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.
pull/20657/head
James Bardin 7 years ago
parent 11ec3a420e
commit 6ecf9b143b

@ -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
}

@ -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())

Loading…
Cancel
Save