github.com/nov1n/terraform@v0.7.9-0.20161103151050-bf6852f38e28/terraform/transform_module_destroy_old.go (about) 1 package terraform 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/terraform/dag" 7 ) 8 9 // ModuleDestroyTransformer is a GraphTransformer that adds a node 10 // to the graph that will just mark the full module for destroy in 11 // the destroy scenario. 12 type ModuleDestroyTransformerOld struct{} 13 14 func (t *ModuleDestroyTransformerOld) Transform(g *Graph) error { 15 // Create the node 16 n := &graphNodeModuleDestroy{Path: g.Path} 17 18 // Add it to the graph. We don't need any edges because 19 // it can happen whenever. 20 g.Add(n) 21 22 return nil 23 } 24 25 type graphNodeModuleDestroy struct { 26 Path []string 27 } 28 29 func (n *graphNodeModuleDestroy) Name() string { 30 return "plan-destroy" 31 } 32 33 // GraphNodeEvalable impl. 34 func (n *graphNodeModuleDestroy) EvalTree() EvalNode { 35 return &EvalOpFilter{ 36 Ops: []walkOperation{walkPlanDestroy}, 37 Node: &EvalDiffDestroyModule{Path: n.Path}, 38 } 39 } 40 41 // GraphNodeFlattenable impl. 42 func (n *graphNodeModuleDestroy) Flatten(p []string) (dag.Vertex, error) { 43 return &graphNodeModuleDestroyFlat{ 44 graphNodeModuleDestroy: n, 45 PathValue: p, 46 }, nil 47 } 48 49 type graphNodeModuleDestroyFlat struct { 50 *graphNodeModuleDestroy 51 52 PathValue []string 53 } 54 55 func (n *graphNodeModuleDestroyFlat) Name() string { 56 return fmt.Sprintf( 57 "%s.%s", modulePrefixStr(n.PathValue), n.graphNodeModuleDestroy.Name()) 58 } 59 60 func (n *graphNodeModuleDestroyFlat) Path() []string { 61 return n.PathValue 62 }