package terraform
-// NodePlanDestroyableResource represents a resource that is "applyable":
-// it is ready to be applied and is represented by a diff.
-type NodePlanDestroyableResource struct {
- *NodeAbstractResource
+import (
+ "fmt"
+
+ "github.com/hashicorp/terraform/addrs"
+ "github.com/hashicorp/terraform/dag"
+ "github.com/hashicorp/terraform/plans"
+ "github.com/hashicorp/terraform/providers"
+ "github.com/hashicorp/terraform/states"
+)
+
+// NodePlanDestroyableResourceInstance represents a resource that is ready
+// to be planned for destruction.
+type NodePlanDestroyableResourceInstance struct {
+ *NodeAbstractResourceInstance
}
+var (
+ _ GraphNodeSubPath = (*NodePlanDestroyableResourceInstance)(nil)
+ _ GraphNodeReferenceable = (*NodePlanDestroyableResourceInstance)(nil)
+ _ GraphNodeReferencer = (*NodePlanDestroyableResourceInstance)(nil)
+ _ GraphNodeDestroyer = (*NodePlanDestroyableResourceInstance)(nil)
+ _ GraphNodeResource = (*NodePlanDestroyableResourceInstance)(nil)
+ _ GraphNodeResourceInstance = (*NodePlanDestroyableResourceInstance)(nil)
+ _ GraphNodeAttachResourceConfig = (*NodePlanDestroyableResourceInstance)(nil)
+ _ GraphNodeAttachResourceState = (*NodePlanDestroyableResourceInstance)(nil)
+ _ GraphNodeEvalable = (*NodePlanDestroyableResourceInstance)(nil)
+ _ GraphNodeProviderConsumer = (*NodePlanDestroyableResourceInstance)(nil)
+)
+
// GraphNodeDestroyer
-func (n *NodePlanDestroyableResource) DestroyAddr() *ResourceAddress {
- return n.Addr
+func (n *NodePlanDestroyableResourceInstance) DestroyAddr() *addrs.AbsResourceInstance {
+ addr := n.ResourceInstanceAddr()
+ return &addr
}
// GraphNodeEvalable
-func (n *NodePlanDestroyableResource) EvalTree() EvalNode {
- addr := n.NodeAbstractResource.Addr
+func (n *NodePlanDestroyableResourceInstance) EvalTree() EvalNode {
+ addr := n.ResourceInstanceAddr()
- // stateId is the ID to put into the state
- stateId := addr.stateId()
+ // Declare a bunch of variables that are used for state during
+ // evaluation. These are written to by address in the EvalNodes we
+ // declare below.
+ var provider providers.Interface
+ var providerSchema *ProviderSchema
+ var change *plans.ResourceInstanceChange
+ var state *states.ResourceInstanceObject
- // Build the instance info. More of this will be populated during eval
- info := &InstanceInfo{
- Id: stateId,
- Type: addr.Type,
+ if n.ResolvedProvider.ProviderConfig.Type == "" {
+ // Should never happen; indicates that the graph was not constructed
+ // correctly since we didn't get our provider attached.
+ panic(fmt.Sprintf("%T %q was not assigned a resolved provider", n, dag.VertexName(n)))
}
- // Declare a bunch of variables that are used for state during
- // evaluation. Most of this are written to by-address below.
- var diff *InstanceDiff
- var state *InstanceState
-
return &EvalSequence{
Nodes: []EvalNode{
+ &EvalGetProvider{
+ Addr: n.ResolvedProvider,
+ Output: &provider,
+ Schema: &providerSchema,
+ },
&EvalReadState{
- Name: stateId,
+ Addr: addr.Resource,
+ Provider: &provider,
+ ProviderSchema: &providerSchema,
+
Output: &state,
},
&EvalDiffDestroy{
- Info: info,
- State: &state,
- Output: &diff,
+ Addr: addr.Resource,
+ ProviderAddr: n.ResolvedProvider,
+ State: &state,
+ Output: &change,
},
&EvalCheckPreventDestroy{
- Resource: n.Config,
- Diff: &diff,
+ Addr: addr.Resource,
+ Config: n.Config,
+ Change: &change,
},
&EvalWriteDiff{
- Name: stateId,
- Diff: &diff,
+ Addr: addr.Resource,
+ ProviderSchema: &providerSchema,
+ Change: &change,
},
},
}