use existing State rather than Change.Before
The change was passed into the provisioner node because the normal NodeApplyableResourceInstance overwrites the prior state with the new state. This however doesn't matter here, because the resource destroy node does not do this. Also, even if the updated state were to be used for some reason with a create provisioner, it would be the correct state to use at that point.
This commit is contained in:
parent
a1181adca4
commit
e35524c7f0
|
@ -505,9 +505,6 @@ type EvalApplyProvisioners struct {
|
||||||
|
|
||||||
// When is the type of provisioner to run at this point
|
// When is the type of provisioner to run at this point
|
||||||
When configs.ProvisionerWhen
|
When configs.ProvisionerWhen
|
||||||
|
|
||||||
// We use the stored change to get the previous resource values in the case of a destroy provisioner
|
|
||||||
Change *plans.ResourceInstanceChange
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: test
|
// TODO: test
|
||||||
|
@ -606,7 +603,7 @@ func (n *EvalApplyProvisioners) apply(ctx EvalContext, provs []*configs.Provisio
|
||||||
|
|
||||||
// this self is only used for destroy provisioner evaluation, and must
|
// this self is only used for destroy provisioner evaluation, and must
|
||||||
// refer to the last known value of the resource.
|
// refer to the last known value of the resource.
|
||||||
self := n.Change.Before
|
self := (*n.State).Value
|
||||||
|
|
||||||
var evalScope func(EvalContext, hcl.Body, cty.Value, *configschema.Block) (cty.Value, tfdiags.Diagnostics)
|
var evalScope func(EvalContext, hcl.Body, cty.Value, *configschema.Block) (cty.Value, tfdiags.Diagnostics)
|
||||||
switch n.When {
|
switch n.When {
|
||||||
|
|
|
@ -394,7 +394,6 @@ func (n *NodeApplyableResourceInstance) managedResourceExecute(ctx EvalContext)
|
||||||
CreateNew: &createNew,
|
CreateNew: &createNew,
|
||||||
Error: &applyError,
|
Error: &applyError,
|
||||||
When: configs.ProvisionerWhenCreate,
|
When: configs.ProvisionerWhenCreate,
|
||||||
Change: diffApply,
|
|
||||||
}
|
}
|
||||||
_, err = applyProvisioners.Eval(ctx)
|
_, err = applyProvisioners.Eval(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -193,7 +193,6 @@ func (n *NodeDestroyResourceInstance) Execute(ctx EvalContext, op walkOperation)
|
||||||
ResourceConfig: n.Config,
|
ResourceConfig: n.Config,
|
||||||
Error: &provisionerErr,
|
Error: &provisionerErr,
|
||||||
When: configs.ProvisionerWhenDestroy,
|
When: configs.ProvisionerWhenDestroy,
|
||||||
Change: changeApply,
|
|
||||||
}
|
}
|
||||||
_, err := evalApplyProvisioners.Eval(ctx)
|
_, err := evalApplyProvisioners.Eval(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue