aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/terraform/terraform/node_resource_plan_destroy.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/terraform/node_resource_plan_destroy.go')
-rw-r--r--vendor/github.com/hashicorp/terraform/terraform/node_resource_plan_destroy.go89
1 files changed, 62 insertions, 27 deletions
diff --git a/vendor/github.com/hashicorp/terraform/terraform/node_resource_plan_destroy.go b/vendor/github.com/hashicorp/terraform/terraform/node_resource_plan_destroy.go
index 9b02362..38746f0 100644
--- a/vendor/github.com/hashicorp/terraform/terraform/node_resource_plan_destroy.go
+++ b/vendor/github.com/hashicorp/terraform/terraform/node_resource_plan_destroy.go
@@ -1,52 +1,87 @@
1package terraform 1package terraform
2 2
3// NodePlanDestroyableResource represents a resource that is "applyable": 3import (
4// it is ready to be applied and is represented by a diff. 4 "fmt"
5type NodePlanDestroyableResource struct { 5
6 *NodeAbstractResource 6 "github.com/hashicorp/terraform/addrs"
7 "github.com/hashicorp/terraform/dag"
8 "github.com/hashicorp/terraform/plans"
9 "github.com/hashicorp/terraform/providers"
10 "github.com/hashicorp/terraform/states"
11)
12
13// NodePlanDestroyableResourceInstance represents a resource that is ready
14// to be planned for destruction.
15type NodePlanDestroyableResourceInstance struct {
16 *NodeAbstractResourceInstance
7} 17}
8 18
19var (
20 _ GraphNodeSubPath = (*NodePlanDestroyableResourceInstance)(nil)
21 _ GraphNodeReferenceable = (*NodePlanDestroyableResourceInstance)(nil)
22 _ GraphNodeReferencer = (*NodePlanDestroyableResourceInstance)(nil)
23 _ GraphNodeDestroyer = (*NodePlanDestroyableResourceInstance)(nil)
24 _ GraphNodeResource = (*NodePlanDestroyableResourceInstance)(nil)
25 _ GraphNodeResourceInstance = (*NodePlanDestroyableResourceInstance)(nil)
26 _ GraphNodeAttachResourceConfig = (*NodePlanDestroyableResourceInstance)(nil)
27 _ GraphNodeAttachResourceState = (*NodePlanDestroyableResourceInstance)(nil)
28 _ GraphNodeEvalable = (*NodePlanDestroyableResourceInstance)(nil)
29 _ GraphNodeProviderConsumer = (*NodePlanDestroyableResourceInstance)(nil)
30)
31
9// GraphNodeDestroyer 32// GraphNodeDestroyer
10func (n *NodePlanDestroyableResource) DestroyAddr() *ResourceAddress { 33func (n *NodePlanDestroyableResourceInstance) DestroyAddr() *addrs.AbsResourceInstance {
11 return n.Addr 34 addr := n.ResourceInstanceAddr()
35 return &addr
12} 36}
13 37
14// GraphNodeEvalable 38// GraphNodeEvalable
15func (n *NodePlanDestroyableResource) EvalTree() EvalNode { 39func (n *NodePlanDestroyableResourceInstance) EvalTree() EvalNode {
16 addr := n.NodeAbstractResource.Addr 40 addr := n.ResourceInstanceAddr()
17 41
18 // stateId is the ID to put into the state 42 // Declare a bunch of variables that are used for state during
19 stateId := addr.stateId() 43 // evaluation. These are written to by address in the EvalNodes we
44 // declare below.
45 var provider providers.Interface
46 var providerSchema *ProviderSchema
47 var change *plans.ResourceInstanceChange
48 var state *states.ResourceInstanceObject
20 49
21 // Build the instance info. More of this will be populated during eval 50 if n.ResolvedProvider.ProviderConfig.Type == "" {
22 info := &InstanceInfo{ 51 // Should never happen; indicates that the graph was not constructed
23 Id: stateId, 52 // correctly since we didn't get our provider attached.
24 Type: addr.Type, 53 panic(fmt.Sprintf("%T %q was not assigned a resolved provider", n, dag.VertexName(n)))
25 } 54 }
26 55
27 // Declare a bunch of variables that are used for state during
28 // evaluation. Most of this are written to by-address below.
29 var diff *InstanceDiff
30 var state *InstanceState
31
32 return &EvalSequence{ 56 return &EvalSequence{
33 Nodes: []EvalNode{ 57 Nodes: []EvalNode{
58 &EvalGetProvider{
59 Addr: n.ResolvedProvider,
60 Output: &provider,
61 Schema: &providerSchema,
62 },
34 &EvalReadState{ 63 &EvalReadState{
35 Name: stateId, 64 Addr: addr.Resource,
65 Provider: &provider,
66 ProviderSchema: &providerSchema,
67
36 Output: &state, 68 Output: &state,
37 }, 69 },
38 &EvalDiffDestroy{ 70 &EvalDiffDestroy{
39 Info: info, 71 Addr: addr.Resource,
40 State: &state, 72 ProviderAddr: n.ResolvedProvider,
41 Output: &diff, 73 State: &state,
74 Output: &change,
42 }, 75 },
43 &EvalCheckPreventDestroy{ 76 &EvalCheckPreventDestroy{
44 Resource: n.Config, 77 Addr: addr.Resource,
45 Diff: &diff, 78 Config: n.Config,
79 Change: &change,
46 }, 80 },
47 &EvalWriteDiff{ 81 &EvalWriteDiff{
48 Name: stateId, 82 Addr: addr.Resource,
49 Diff: &diff, 83 ProviderSchema: &providerSchema,
84 Change: &change,
50 }, 85 },
51 }, 86 },
52 } 87 }