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.
This commit is contained in:
James Bardin 2019-01-17 18:58:56 -05:00
parent 4f691c5988
commit 286cb0a39d
1 changed files with 11 additions and 8 deletions

View File

@ -513,7 +513,17 @@ func (s *GRPCProviderServer) PlanResourceChange(_ context.Context, req *proto.Pl
return resp, nil 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 // 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 // changes, but our new interface wants us to return an actual change
// description that _shows_ there are no changes. This is usually the // 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 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 { if priorState == nil {
priorState = &terraform.InstanceState{} priorState = &terraform.InstanceState{}
} }