terraform: plan destroy
This commit is contained in:
parent
00f4245572
commit
e185769271
|
@ -826,8 +826,7 @@ func TestContext2Plan_countIncreaseFromOne(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestContextPlan_destroy(t *testing.T) {
|
||||
func TestContext2Plan_destroy(t *testing.T) {
|
||||
m := testModule(t, "plan-destroy")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
|
@ -852,7 +851,7 @@ func TestContextPlan_destroy(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
|
@ -876,6 +875,7 @@ func TestContextPlan_destroy(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestContextPlan_moduleDestroy(t *testing.T) {
|
||||
m := testModule(t, "plan-module-destroy")
|
||||
p := testProvider("aws")
|
||||
|
|
|
@ -117,6 +117,11 @@ func (n *EvalDiffDestroy) Eval(
|
|||
state = args[0].(*InstanceState)
|
||||
}
|
||||
|
||||
// If there is no state or we don't have an ID, we're already destroyed
|
||||
if state == nil || state.ID == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Call pre-diff hook
|
||||
err := ctx.Hook(func(h Hook) (HookAction, error) {
|
||||
return h.PreDiff(n.Info, state)
|
||||
|
|
|
@ -197,7 +197,7 @@ func (n *graphNodeOrphanResource) EvalTree() EvalNode {
|
|||
// Diff the resource
|
||||
var diff InstanceDiff
|
||||
seq.Nodes = append(seq.Nodes, &EvalOpFilter{
|
||||
Ops: []walkOperation{walkPlan},
|
||||
Ops: []walkOperation{walkPlan, walkPlanDestroy},
|
||||
Node: &EvalSequence{
|
||||
Nodes: []EvalNode{
|
||||
&EvalDiffDestroy{
|
||||
|
|
|
@ -183,6 +183,24 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode {
|
|||
},
|
||||
})
|
||||
|
||||
// Diff the resource for destruction
|
||||
seq.Nodes = append(seq.Nodes, &EvalOpFilter{
|
||||
Ops: []walkOperation{walkPlanDestroy},
|
||||
Node: &EvalSequence{
|
||||
Nodes: []EvalNode{
|
||||
&EvalDiffDestroy{
|
||||
Info: info,
|
||||
State: &EvalReadState{Name: n.stateId()},
|
||||
Output: &diff,
|
||||
},
|
||||
&EvalWriteDiff{
|
||||
Name: n.stateId(),
|
||||
Diff: &diff,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
return seq
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue