github.com/rhenning/terraform@v0.8.0-beta2/terraform/node_resource_plan_destroy.go (about) 1 package terraform 2 3 import ( 4 "fmt" 5 ) 6 7 // NodePlanDestroyableResource represents a resource that is "applyable": 8 // it is ready to be applied and is represented by a diff. 9 type NodePlanDestroyableResource struct { 10 *NodeAbstractResource 11 } 12 13 // GraphNodeDestroyer 14 func (n *NodePlanDestroyableResource) DestroyAddr() *ResourceAddress { 15 return n.Addr 16 } 17 18 // GraphNodeEvalable 19 func (n *NodePlanDestroyableResource) EvalTree() EvalNode { 20 addr := n.NodeAbstractResource.Addr 21 22 // stateId is the ID to put into the state 23 stateId := addr.stateId() 24 if addr.Index > -1 { 25 stateId = fmt.Sprintf("%s.%d", stateId, addr.Index) 26 } 27 28 // Build the instance info. More of this will be populated during eval 29 info := &InstanceInfo{ 30 Id: stateId, 31 Type: addr.Type, 32 } 33 34 // Declare a bunch of variables that are used for state during 35 // evaluation. Most of this are written to by-address below. 36 var diff *InstanceDiff 37 var state *InstanceState 38 39 return &EvalSequence{ 40 Nodes: []EvalNode{ 41 &EvalReadState{ 42 Name: stateId, 43 Output: &state, 44 }, 45 &EvalDiffDestroy{ 46 Info: info, 47 State: &state, 48 Output: &diff, 49 }, 50 &EvalCheckPreventDestroy{ 51 Resource: n.Config, 52 Diff: &diff, 53 }, 54 &EvalWriteDiff{ 55 Name: stateId, 56 Diff: &diff, 57 }, 58 }, 59 } 60 }