mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
d992f8d52d
The nodes it adds were immediately skipped by flattening and therefore never had any effect. That makes the transformer effectively dead code and removable. This was the only usage of FlattenSkip so we can remove that as well.
63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package terraform
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/terraform/dag"
|
|
)
|
|
|
|
// ModuleDestroyTransformer is a GraphTransformer that adds a node
|
|
// to the graph that will just mark the full module for destroy in
|
|
// the destroy scenario.
|
|
type ModuleDestroyTransformer struct{}
|
|
|
|
func (t *ModuleDestroyTransformer) Transform(g *Graph) error {
|
|
// Create the node
|
|
n := &graphNodeModuleDestroy{Path: g.Path}
|
|
|
|
// Add it to the graph. We don't need any edges because
|
|
// it can happen whenever.
|
|
g.Add(n)
|
|
|
|
return nil
|
|
}
|
|
|
|
type graphNodeModuleDestroy struct {
|
|
Path []string
|
|
}
|
|
|
|
func (n *graphNodeModuleDestroy) Name() string {
|
|
return "plan-destroy"
|
|
}
|
|
|
|
// GraphNodeEvalable impl.
|
|
func (n *graphNodeModuleDestroy) EvalTree() EvalNode {
|
|
return &EvalOpFilter{
|
|
Ops: []walkOperation{walkPlanDestroy},
|
|
Node: &EvalDiffDestroyModule{Path: n.Path},
|
|
}
|
|
}
|
|
|
|
// GraphNodeFlattenable impl.
|
|
func (n *graphNodeModuleDestroy) Flatten(p []string) (dag.Vertex, error) {
|
|
return &graphNodeModuleDestroyFlat{
|
|
graphNodeModuleDestroy: n,
|
|
PathValue: p,
|
|
}, nil
|
|
}
|
|
|
|
type graphNodeModuleDestroyFlat struct {
|
|
*graphNodeModuleDestroy
|
|
|
|
PathValue []string
|
|
}
|
|
|
|
func (n *graphNodeModuleDestroyFlat) Name() string {
|
|
return fmt.Sprintf(
|
|
"%s.%s", modulePrefixStr(n.PathValue), n.graphNodeModuleDestroy.Name())
|
|
}
|
|
|
|
func (n *graphNodeModuleDestroyFlat) Path() []string {
|
|
return n.PathValue
|
|
}
|