if there is no plan diff, prefer the prior state

The prior state may contain customizations made by the provider. If
there is no prior state, then take the proposed state.
This commit is contained in:
James Bardin 2018-10-30 15:58:00 -04:00
parent 36cede09f7
commit e0ea2a5d06
1 changed files with 10 additions and 5 deletions

View File

@ -476,11 +476,16 @@ func (s *GRPCProviderServer) PlanResourceChange(_ context.Context, req *proto.Pl
}
if diff == nil {
// 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, so we return
// the proposed change that produces no diff.
resp.PlannedState = req.ProposedNewState
// 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
// PriorSate, however if there was no prior state and no diff, then we
// use the ProposedNewState.
if !priorStateVal.IsNull() {
resp.PlannedState = req.PriorState
} else {
resp.PlannedState = req.ProposedNewState
}
return resp, nil
}