github.com/wikibal01/hashicorp-terraform@v0.11.12-beta1/terraform/node_resource_plan_orphan.go (about)

     1  package terraform
     2  
     3  // NodePlannableResourceOrphan represents a resource that is "applyable":
     4  // it is ready to be applied and is represented by a diff.
     5  type NodePlannableResourceOrphan struct {
     6  	*NodeAbstractResource
     7  }
     8  
     9  func (n *NodePlannableResourceOrphan) Name() string {
    10  	return n.NodeAbstractResource.Name() + " (orphan)"
    11  }
    12  
    13  // GraphNodeEvalable
    14  func (n *NodePlannableResourceOrphan) EvalTree() EvalNode {
    15  	addr := n.NodeAbstractResource.Addr
    16  
    17  	// stateId is the ID to put into the state
    18  	stateId := addr.stateId()
    19  
    20  	// Build the instance info. More of this will be populated during eval
    21  	info := &InstanceInfo{
    22  		Id:         stateId,
    23  		Type:       addr.Type,
    24  		ModulePath: normalizeModulePath(addr.Path),
    25  	}
    26  
    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{
    33  		Nodes: []EvalNode{
    34  			&EvalReadState{
    35  				Name:   stateId,
    36  				Output: &state,
    37  			},
    38  			&EvalDiffDestroy{
    39  				Info:   info,
    40  				State:  &state,
    41  				Output: &diff,
    42  			},
    43  			&EvalCheckPreventDestroy{
    44  				Resource:   n.Config,
    45  				ResourceId: stateId,
    46  				Diff:       &diff,
    47  			},
    48  			&EvalWriteDiff{
    49  				Name: stateId,
    50  				Diff: &diff,
    51  			},
    52  		},
    53  	}
    54  }