From 4f691c598857496ef96984b27c550d78d1244c7e Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 17 Jan 2019 18:44:31 -0500 Subject: [PATCH] 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. --- helper/plugin/grpc_provider.go | 7 ------- helper/plugin/grpc_provider_test.go | 21 --------------------- 2 files changed, 28 deletions(-) diff --git a/helper/plugin/grpc_provider.go b/helper/plugin/grpc_provider.go index 63f41af41..9ee006cbc 100644 --- a/helper/plugin/grpc_provider.go +++ b/helper/plugin/grpc_provider.go @@ -1119,13 +1119,6 @@ func stripSchema(s *schema.Schema) *schema.Schema { func copyMissingValues(dst, src cty.Value) cty.Value { 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() { return dst } diff --git a/helper/plugin/grpc_provider_test.go b/helper/plugin/grpc_provider_test.go index 4df64cdac..96799b868 100644 --- a/helper/plugin/grpc_provider_test.go +++ b/helper/plugin/grpc_provider_test.go @@ -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) { got := copyMissingValues(tc.Dst, tc.Src)