core: EvalCheckPlannedChange to check change action

Previously we were checking only the before and after values, and not
verifying that the change action is unchanged between plan and apply.
This commit is contained in:
Martin Atkins 2018-09-04 16:52:13 -07:00
parent b428746cfd
commit 6365b9ec7f
1 changed files with 16 additions and 1 deletions

View File

@ -50,8 +50,23 @@ func (n *EvalCheckPlannedChange) Eval(ctx EvalContext) (interface{}, error) {
return nil, fmt.Errorf("provider does not support resource type %q", n.Addr.Resource.Type)
}
absAddr := n.Addr.Absolute(ctx.Path())
var diags tfdiags.Diagnostics
absAddr := n.Addr.Absolute(ctx.Path())
log.Printf("[TRACE] EvalCheckPlannedChange: Verifying that actual change (action %s) matches planned change (action %s)", actualChange.Action, plannedChange.Action)
if plannedChange.Action != actualChange.Action {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Provider produced inconsistent final plan",
fmt.Sprintf(
"When expanding the plan for %s to include new values learned so far during apply, provider %q changed the planned action from %s to %s.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.",
absAddr, n.ProviderAddr.ProviderConfig.Type,
plannedChange.Action, actualChange.Action,
),
))
}
errs := objchange.AssertObjectCompatible(schema, plannedChange.After, actualChange.After)
for _, err := range errs {
diags = diags.Append(tfdiags.Sourceless(