github.com/ns1/terraform@v0.7.10-0.20161109153551-8949419bef40/terraform/graph_builder_destroy_plan.go (about) 1 package terraform 2 3 import ( 4 "github.com/hashicorp/terraform/config/module" 5 "github.com/hashicorp/terraform/dag" 6 ) 7 8 // DestroyPlanGraphBuilder implements GraphBuilder and is responsible for 9 // planning a pure-destroy. 10 // 11 // Planning a pure destroy operation is simple because we can ignore most 12 // ordering configuration and simply reverse the state. 13 type DestroyPlanGraphBuilder struct { 14 // Module is the root module for the graph to build. 15 Module *module.Tree 16 17 // State is the current state 18 State *State 19 20 // Targets are resources to target 21 Targets []string 22 } 23 24 // See GraphBuilder 25 func (b *DestroyPlanGraphBuilder) Build(path []string) (*Graph, error) { 26 return (&BasicGraphBuilder{ 27 Steps: b.Steps(), 28 Validate: true, 29 Name: "destroy", 30 }).Build(path) 31 } 32 33 // See GraphBuilder 34 func (b *DestroyPlanGraphBuilder) Steps() []GraphTransformer { 35 concreteResource := func(a *NodeAbstractResource) dag.Vertex { 36 return &NodePlanDestroyableResource{ 37 NodeAbstractResource: a, 38 } 39 } 40 41 steps := []GraphTransformer{ 42 // Creates all the nodes represented in the state. 43 &StateTransformer{ 44 Concrete: concreteResource, 45 State: b.State, 46 }, 47 48 // Target 49 &TargetsTransformer{Targets: b.Targets}, 50 51 // Attach the configuration to any resources 52 &AttachResourceConfigTransformer{Module: b.Module}, 53 54 // Single root 55 &RootTransformer{}, 56 } 57 58 return steps 59 }