don't replace null strings with empty strings
This adds unexpected values in some cases, and since the case this handles is only within set objects, we'll deal woth this when tackling the sets themselves.
This commit is contained in:
parent
2cc651124e
commit
4f691c5988
|
@ -1119,13 +1119,6 @@ func stripSchema(s *schema.Schema) *schema.Schema {
|
||||||
func copyMissingValues(dst, src cty.Value) cty.Value {
|
func copyMissingValues(dst, src cty.Value) cty.Value {
|
||||||
ty := dst.Type()
|
ty := dst.Type()
|
||||||
|
|
||||||
// In this case the provider set an empty string which was lost in
|
|
||||||
// conversion. Since src is unknown, there must have been a corresponding
|
|
||||||
// value set.
|
|
||||||
if ty == cty.String && dst.IsNull() && !src.IsKnown() {
|
|
||||||
return cty.StringVal("")
|
|
||||||
}
|
|
||||||
|
|
||||||
if src.IsNull() || !src.IsKnown() || !dst.IsKnown() {
|
if src.IsNull() || !src.IsKnown() || !dst.IsKnown() {
|
||||||
return dst
|
return dst
|
||||||
}
|
}
|
||||||
|
|
|
@ -821,27 +821,6 @@ func TestCopyMissingValues(t *testing.T) {
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
// Recover the lost unknown key, assuming it was set to an empty
|
|
||||||
// string and lost.
|
|
||||||
Src: cty.ObjectVal(map[string]cty.Value{
|
|
||||||
"map": cty.MapVal(map[string]cty.Value{
|
|
||||||
"a": cty.StringVal("a"),
|
|
||||||
"b": cty.UnknownVal(cty.String),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
Dst: cty.ObjectVal(map[string]cty.Value{
|
|
||||||
"map": cty.MapVal(map[string]cty.Value{
|
|
||||||
"a": cty.StringVal("a"),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
Expect: cty.ObjectVal(map[string]cty.Value{
|
|
||||||
"map": cty.MapVal(map[string]cty.Value{
|
|
||||||
"a": cty.StringVal("a"),
|
|
||||||
"b": cty.StringVal(""),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
} {
|
} {
|
||||||
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
|
||||||
got := copyMissingValues(tc.Dst, tc.Src)
|
got := copyMissingValues(tc.Dst, tc.Src)
|
||||||
|
|
Loading…
Reference in New Issue