terraform: destroy module plan
This commit is contained in:
parent
e185769271
commit
ec6ce69e90
|
@ -875,8 +875,7 @@ func TestContext2Plan_destroy(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
func TestContext2Plan_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")
|
||||||
p.DiffFn = testDiffFn
|
p.DiffFn = testDiffFn
|
||||||
|
@ -906,7 +905,7 @@ func TestContextPlan_moduleDestroy(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),
|
||||||
|
@ -926,6 +925,7 @@ func TestContextPlan_moduleDestroy(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func TestContextPlan_moduleDestroyMultivar(t *testing.T) {
|
func TestContextPlan_moduleDestroyMultivar(t *testing.T) {
|
||||||
m := testModule(t, "plan-module-destroy-multivar")
|
m := testModule(t, "plan-module-destroy-multivar")
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
|
|
|
@ -151,6 +151,39 @@ func (n *EvalDiffDestroy) Type() EvalType {
|
||||||
return EvalTypeNull
|
return EvalTypeNull
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EvalDiffDestroyModule is an EvalNode implementation that writes the diff to
|
||||||
|
// the full diff.
|
||||||
|
type EvalDiffDestroyModule struct {
|
||||||
|
Path []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *EvalDiffDestroyModule) Args() ([]EvalNode, []EvalType) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: test
|
||||||
|
func (n *EvalDiffDestroyModule) Eval(
|
||||||
|
ctx EvalContext, args []interface{}) (interface{}, error) {
|
||||||
|
diff, lock := ctx.Diff()
|
||||||
|
|
||||||
|
// Acquire the lock so that we can do this safely concurrently
|
||||||
|
lock.Lock()
|
||||||
|
defer lock.Unlock()
|
||||||
|
|
||||||
|
// Write the diff
|
||||||
|
modDiff := diff.ModuleByPath(n.Path)
|
||||||
|
if modDiff == nil {
|
||||||
|
modDiff = diff.AddModule(n.Path)
|
||||||
|
}
|
||||||
|
modDiff.Destroy = true
|
||||||
|
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *EvalDiffDestroyModule) Type() EvalType {
|
||||||
|
return EvalTypeNull
|
||||||
|
}
|
||||||
|
|
||||||
// EvalWriteDiff is an EvalNode implementation that writes the diff to
|
// EvalWriteDiff is an EvalNode implementation that writes the diff to
|
||||||
// the full diff.
|
// the full diff.
|
||||||
type EvalWriteDiff struct {
|
type EvalWriteDiff struct {
|
||||||
|
|
|
@ -306,9 +306,22 @@ func (n *graphNodeModuleExpanded) Name() string {
|
||||||
|
|
||||||
// GraphNodeEvalable impl.
|
// GraphNodeEvalable impl.
|
||||||
func (n *graphNodeModuleExpanded) EvalTree() EvalNode {
|
func (n *graphNodeModuleExpanded) EvalTree() EvalNode {
|
||||||
return &EvalVariableBlock{
|
return &EvalSequence{
|
||||||
Config: &EvalInterpolate{Config: n.InputConfig},
|
Nodes: []EvalNode{
|
||||||
Variables: n.Variables,
|
&EvalVariableBlock{
|
||||||
|
Config: &EvalInterpolate{Config: n.InputConfig},
|
||||||
|
Variables: n.Variables,
|
||||||
|
},
|
||||||
|
|
||||||
|
&EvalOpFilter{
|
||||||
|
Ops: []walkOperation{walkPlanDestroy},
|
||||||
|
Node: &EvalSequence{
|
||||||
|
Nodes: []EvalNode{
|
||||||
|
&EvalDiffDestroyModule{Path: n.Graph.Path},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue