mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
terraform: plan destroy
This commit is contained in:
parent
00f4245572
commit
e185769271
@ -826,8 +826,7 @@ func TestContext2Plan_countIncreaseFromOne(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
func TestContext2Plan_destroy(t *testing.T) {
|
||||||
func TestContextPlan_destroy(t *testing.T) {
|
|
||||||
m := testModule(t, "plan-destroy")
|
m := testModule(t, "plan-destroy")
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
p.DiffFn = testDiffFn
|
p.DiffFn = testDiffFn
|
||||||
@ -852,7 +851,7 @@ func TestContextPlan_destroy(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ctx := testContext(t, &ContextOpts{
|
ctx := testContext2(t, &ContextOpts{
|
||||||
Module: m,
|
Module: m,
|
||||||
Providers: map[string]ResourceProviderFactory{
|
Providers: map[string]ResourceProviderFactory{
|
||||||
"aws": testProviderFuncFixed(p),
|
"aws": testProviderFuncFixed(p),
|
||||||
@ -876,6 +875,7 @@ func TestContextPlan_destroy(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func TestContextPlan_moduleDestroy(t *testing.T) {
|
func TestContextPlan_moduleDestroy(t *testing.T) {
|
||||||
m := testModule(t, "plan-module-destroy")
|
m := testModule(t, "plan-module-destroy")
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
|
@ -117,6 +117,11 @@ func (n *EvalDiffDestroy) Eval(
|
|||||||
state = args[0].(*InstanceState)
|
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
|
// Call pre-diff hook
|
||||||
err := ctx.Hook(func(h Hook) (HookAction, error) {
|
err := ctx.Hook(func(h Hook) (HookAction, error) {
|
||||||
return h.PreDiff(n.Info, state)
|
return h.PreDiff(n.Info, state)
|
||||||
|
@ -197,7 +197,7 @@ func (n *graphNodeOrphanResource) EvalTree() EvalNode {
|
|||||||
// Diff the resource
|
// Diff the resource
|
||||||
var diff InstanceDiff
|
var diff InstanceDiff
|
||||||
seq.Nodes = append(seq.Nodes, &EvalOpFilter{
|
seq.Nodes = append(seq.Nodes, &EvalOpFilter{
|
||||||
Ops: []walkOperation{walkPlan},
|
Ops: []walkOperation{walkPlan, walkPlanDestroy},
|
||||||
Node: &EvalSequence{
|
Node: &EvalSequence{
|
||||||
Nodes: []EvalNode{
|
Nodes: []EvalNode{
|
||||||
&EvalDiffDestroy{
|
&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
|
return seq
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user