From 209a0a460a6ae553b2b728308bda3cdb50b67851 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 6 Mar 2019 14:09:01 -0500 Subject: [PATCH] normalize all objects read from the provider Use objchange.NormalizeObjectFromLegacySDK to ensure that all objects returned from the provider match what is expected based on the configuration according to the schemas. --- helper/plugin/grpc_provider.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/helper/plugin/grpc_provider.go b/helper/plugin/grpc_provider.go index 1b046f9d91..99877bd3d2 100644 --- a/helper/plugin/grpc_provider.go +++ b/helper/plugin/grpc_provider.go @@ -9,6 +9,8 @@ import ( "strconv" "strings" + "github.com/hashicorp/terraform/plans/objchange" + "github.com/zclconf/go-cty/cty" ctyconvert "github.com/zclconf/go-cty/cty/convert" "github.com/zclconf/go-cty/cty/msgpack" @@ -458,6 +460,7 @@ func (s *GRPCProviderServer) ReadResource(_ context.Context, req *proto.ReadReso } newStateVal = copyTimeoutValues(newStateVal, stateVal) + newStateVal = objchange.NormalizeObjectFromLegacySDK(newStateVal, block) newStateMP, err := msgpack.Marshal(newStateVal, block.ImpliedType()) if err != nil { @@ -594,6 +597,7 @@ func (s *GRPCProviderServer) PlanResourceChange(_ context.Context, req *proto.Pl } plannedStateVal = copyTimeoutValues(plannedStateVal, proposedNewStateVal) + plannedStateVal = objchange.NormalizeObjectFromLegacySDK(plannedStateVal, block) // The old SDK code has some imprecisions that cause it to sometimes // generate differences that the SDK itself does not consider significant @@ -832,6 +836,7 @@ func (s *GRPCProviderServer) ApplyResourceChange(_ context.Context, req *proto.A newStateVal = normalizeNullValues(newStateVal, plannedStateVal, false) newStateVal = copyTimeoutValues(newStateVal, plannedStateVal) + newStateVal = objchange.NormalizeObjectFromLegacySDK(newStateVal, block) newStateMP, err := msgpack.Marshal(newStateVal, block.ImpliedType()) if err != nil { @@ -955,6 +960,7 @@ func (s *GRPCProviderServer) ReadDataSource(_ context.Context, req *proto.ReadDa } newStateVal = copyTimeoutValues(newStateVal, configVal) + newStateVal = objchange.NormalizeObjectFromLegacySDK(newStateVal, block) newStateMP, err := msgpack.Marshal(newStateVal, block.ImpliedType()) if err != nil {