github.com/hashicorp/terraform-plugin-sdk@v1.17.2/terraform/node_resource_plan_orphan.go (about) 1 package terraform 2 3 import ( 4 "github.com/hashicorp/terraform-plugin-sdk/internal/plans" 5 "github.com/hashicorp/terraform-plugin-sdk/internal/providers" 6 "github.com/hashicorp/terraform-plugin-sdk/internal/states" 7 ) 8 9 // NodePlannableResourceInstanceOrphan represents a resource that is "applyable": 10 // it is ready to be applied and is represented by a diff. 11 type NodePlannableResourceInstanceOrphan struct { 12 *NodeAbstractResourceInstance 13 } 14 15 var ( 16 _ GraphNodeSubPath = (*NodePlannableResourceInstanceOrphan)(nil) 17 _ GraphNodeReferenceable = (*NodePlannableResourceInstanceOrphan)(nil) 18 _ GraphNodeReferencer = (*NodePlannableResourceInstanceOrphan)(nil) 19 _ GraphNodeResource = (*NodePlannableResourceInstanceOrphan)(nil) 20 _ GraphNodeResourceInstance = (*NodePlannableResourceInstanceOrphan)(nil) 21 _ GraphNodeAttachResourceConfig = (*NodePlannableResourceInstanceOrphan)(nil) 22 _ GraphNodeAttachResourceState = (*NodePlannableResourceInstanceOrphan)(nil) 23 _ GraphNodeEvalable = (*NodePlannableResourceInstanceOrphan)(nil) 24 ) 25 26 var ( 27 _ GraphNodeEvalable = (*NodePlannableResourceInstanceOrphan)(nil) 28 ) 29 30 func (n *NodePlannableResourceInstanceOrphan) Name() string { 31 return n.ResourceInstanceAddr().String() + " (orphan)" 32 } 33 34 // GraphNodeEvalable 35 func (n *NodePlannableResourceInstanceOrphan) EvalTree() EvalNode { 36 addr := n.ResourceInstanceAddr() 37 38 // Declare a bunch of variables that are used for state during 39 // evaluation. Most of this are written to by-address below. 40 var change *plans.ResourceInstanceChange 41 var state *states.ResourceInstanceObject 42 var provider providers.Interface 43 var providerSchema *ProviderSchema 44 45 return &EvalSequence{ 46 Nodes: []EvalNode{ 47 &EvalGetProvider{ 48 Addr: n.ResolvedProvider, 49 Output: &provider, 50 Schema: &providerSchema, 51 }, 52 &EvalReadState{ 53 Addr: addr.Resource, 54 Provider: &provider, 55 ProviderSchema: &providerSchema, 56 57 Output: &state, 58 }, 59 &EvalDiffDestroy{ 60 Addr: addr.Resource, 61 State: &state, 62 ProviderAddr: n.ResolvedProvider, 63 Output: &change, 64 OutputState: &state, // Will point to a nil state after this complete, signalling destroyed 65 }, 66 &EvalCheckPreventDestroy{ 67 Addr: addr.Resource, 68 Config: n.Config, 69 Change: &change, 70 }, 71 &EvalWriteDiff{ 72 Addr: addr.Resource, 73 ProviderSchema: &providerSchema, 74 Change: &change, 75 }, 76 &EvalWriteState{ 77 Addr: addr.Resource, 78 ProviderAddr: n.ResolvedProvider, 79 ProviderSchema: &providerSchema, 80 State: &state, 81 }, 82 }, 83 } 84 }