core: EvalDiffDestroy only update state if requested
The earlier change 5f07201a made it so that the state is always rewritten by EvalDiffDestroy, but that was too disruptive to other users of EvalDiffDestroy. Now we follow the lead of EvalDiff and have a separate pointer for the _output_ state, which allows the caller to opt in to having its state pointer updated to reflect the new (nil) state. NodePlannableResourceInstanceOrphan is the only caller that currently opts in to this, since that was the focus of 5f07201a. We may need to make a similar change to other plannable resource destroy nodes, but we'll wait to see if that needs to be done in a subsequent commit.
This commit is contained in:
parent
883f40cdb4
commit
fb70eaa7d1
|
@ -427,6 +427,7 @@ type EvalDiffDestroy struct {
|
||||||
Addr addrs.ResourceInstance
|
Addr addrs.ResourceInstance
|
||||||
State **InstanceState
|
State **InstanceState
|
||||||
Output **InstanceDiff
|
Output **InstanceDiff
|
||||||
|
OutputState **InstanceState
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: test
|
// TODO: test
|
||||||
|
@ -463,9 +464,9 @@ func (n *EvalDiffDestroy) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
// Update our output
|
// Update our output
|
||||||
*n.Output = diff
|
*n.Output = diff
|
||||||
|
|
||||||
if n.State != nil {
|
if n.OutputState != nil {
|
||||||
// Record our proposed new state, which is nil because we're destroying.
|
// Record our proposed new state, which is nil because we're destroying.
|
||||||
*n.State = nil
|
*n.OutputState = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
@ -46,8 +46,9 @@ func (n *NodePlannableResourceInstanceOrphan) EvalTree() EvalNode {
|
||||||
},
|
},
|
||||||
&EvalDiffDestroy{
|
&EvalDiffDestroy{
|
||||||
Addr: addr.Resource,
|
Addr: addr.Resource,
|
||||||
State: &state, // Will point to a nil state after this complete, signalling destroyed
|
State: &state,
|
||||||
Output: &diff,
|
Output: &diff,
|
||||||
|
OutputState: &state, // Will point to a nil state after this complete, signalling destroyed
|
||||||
},
|
},
|
||||||
&EvalCheckPreventDestroy{
|
&EvalCheckPreventDestroy{
|
||||||
Addr: addr.Resource,
|
Addr: addr.Resource,
|
||||||
|
|
Loading…
Reference in New Issue