From 286cb0a39d729446c2de62256d06b1efc5273d7a Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 17 Jan 2019 18:58:56 -0500 Subject: [PATCH] clean out diff a little more before checking Check if there wasn't any real diff attributes first, before returning the original state in PlanResourceChange. --- helper/plugin/grpc_provider.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/helper/plugin/grpc_provider.go b/helper/plugin/grpc_provider.go index 9ee006cbc..46c44ca8c 100644 --- a/helper/plugin/grpc_provider.go +++ b/helper/plugin/grpc_provider.go @@ -513,7 +513,17 @@ func (s *GRPCProviderServer) PlanResourceChange(_ context.Context, req *proto.Pl return resp, nil } - if diff == nil { + if diff != nil { + // strip out non-diffs + for k, v := range diff.Attributes { + if v.New == v.Old && !v.NewComputed { + delete(diff.Attributes, k) + } + } + + } + + if diff == nil || len(diff.Attributes) == 0 { // schema.Provider.Diff returns nil if it ends up making a diff with no // changes, but our new interface wants us to return an actual change // description that _shows_ there are no changes. This is usually the @@ -527,13 +537,6 @@ func (s *GRPCProviderServer) PlanResourceChange(_ context.Context, req *proto.Pl return resp, nil } - // strip out non-diffs - for k, v := range diff.Attributes { - if v.New == v.Old && !v.NewComputed { - delete(diff.Attributes, k) - } - } - if priorState == nil { priorState = &terraform.InstanceState{} }