don't use an *error in the postApplyHook

This commit is contained in:
James Bardin 2021-01-13 15:14:32 -05:00
parent 685022fae7
commit 3f3565d48a
4 changed files with 6 additions and 8 deletions

View File

@ -232,7 +232,7 @@ func (n *NodeAbstractResourceInstance) preApplyHook(ctx EvalContext, change *pla
} }
// postApplyHook calls the post-Apply hook // postApplyHook calls the post-Apply hook
func (n *NodeAbstractResourceInstance) postApplyHook(ctx EvalContext, state *states.ResourceInstanceObject, err *error) tfdiags.Diagnostics { func (n *NodeAbstractResourceInstance) postApplyHook(ctx EvalContext, state *states.ResourceInstanceObject, err error) tfdiags.Diagnostics {
var diags tfdiags.Diagnostics var diags tfdiags.Diagnostics
// Only managed resources have user-visible apply actions. // Only managed resources have user-visible apply actions.
@ -244,7 +244,7 @@ func (n *NodeAbstractResourceInstance) postApplyHook(ctx EvalContext, state *sta
newState = cty.NullVal(cty.DynamicPseudoType) newState = cty.NullVal(cty.DynamicPseudoType)
} }
diags = diags.Append(ctx.Hook(func(h Hook) (HookAction, error) { diags = diags.Append(ctx.Hook(func(h Hook) (HookAction, error) {
return h.PostApply(n.Addr, nil, newState, *err) return h.PostApply(n.Addr, nil, newState, err)
})) }))
} }

View File

@ -326,7 +326,7 @@ func (n *NodeApplyableResourceInstance) managedResourceExecute(ctx EvalContext)
} }
} }
diags = diags.Append(n.postApplyHook(ctx, state, &applyErr)) diags = diags.Append(n.postApplyHook(ctx, state, diags.Err()))
diags = diags.Append(applyDiags) diags = diags.Append(applyDiags)
diags = diags.Append(updateStateHook(ctx)) diags = diags.Append(updateStateHook(ctx))
return diags return diags

View File

@ -182,7 +182,7 @@ func (n *NodeDestroyResourceInstance) Execute(ctx EvalContext, op walkOperation)
if provisionerErr != nil { if provisionerErr != nil {
// If we have a provisioning error, then we just call // If we have a provisioning error, then we just call
// the post-apply hook now. // the post-apply hook now.
diags = diags.Append(n.postApplyHook(ctx, state, &provisionerErr)) diags = diags.Append(n.postApplyHook(ctx, state, provisionerErr))
return diags.Append(applyProvisionersDiags) return diags.Append(applyProvisionersDiags)
} }
} }
@ -210,8 +210,7 @@ func (n *NodeDestroyResourceInstance) Execute(ctx EvalContext, op walkOperation)
} }
// create the err value for postApplyHook // create the err value for postApplyHook
applyErr := applyDiags.Err() diags = diags.Append(n.postApplyHook(ctx, state, applyDiags.Err()))
diags = diags.Append(n.postApplyHook(ctx, state, &applyErr))
diags = diags.Append(applyDiags) diags = diags.Append(applyDiags)
diags = diags.Append(updateStateHook(ctx)) diags = diags.Append(updateStateHook(ctx))

View File

@ -185,8 +185,7 @@ func (n *NodeDestroyDeposedResourceInstanceObject) Execute(ctx EvalContext, op w
return diags.Append(applyDiags) return diags.Append(applyDiags)
} }
applyErr := applyDiags.Err() diags = diags.Append(n.postApplyHook(ctx, state, applyDiags.Err()))
diags = diags.Append(n.postApplyHook(ctx, state, &applyErr))
diags = diags.Append(applyDiags) diags = diags.Append(applyDiags)
return diags.Append(updateStateHook(ctx)) return diags.Append(updateStateHook(ctx))