github.com/ns1/terraform@v0.7.10-0.20161109153551-8949419bef40/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 // GraphNodeEvalable 14 func (n *NodePlanDestroyableResource) EvalTree() EvalNode { 15 addr := n.NodeAbstractResource.Addr 16 17 // stateId is the ID to put into the state 18 stateId := addr.stateId() 19 if addr.Index > -1 { 20 stateId = fmt.Sprintf("%s.%d", stateId, addr.Index) 21 } 22 23 // Build the instance info. More of this will be populated during eval 24 info := &InstanceInfo{ 25 Id: stateId, 26 Type: addr.Type, 27 } 28 29 // Declare a bunch of variables that are used for state during 30 // evaluation. Most of this are written to by-address below. 31 var diff *InstanceDiff 32 var state *InstanceState 33 34 return &EvalSequence{ 35 Nodes: []EvalNode{ 36 &EvalReadState{ 37 Name: stateId, 38 Output: &state, 39 }, 40 &EvalDiffDestroy{ 41 Info: info, 42 State: &state, 43 Output: &diff, 44 }, 45 &EvalCheckPreventDestroy{ 46 Resource: n.Config, 47 Diff: &diff, 48 }, 49 &EvalWriteDiff{ 50 Name: stateId, 51 Diff: &diff, 52 }, 53 }, 54 } 55 }