github.com/nov1n/terraform@v0.7.9-0.20161103151050-bf6852f38e28/terraform/node_output.go (about)

     1  package terraform
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/hashicorp/terraform/config"
     7  )
     8  
     9  // NodeApplyableOutput represents an output that is "applyable":
    10  // it is ready to be applied.
    11  type NodeApplyableOutput struct {
    12  	PathValue []string
    13  	Config    *config.Output // Config is the output in the config
    14  }
    15  
    16  func (n *NodeApplyableOutput) Name() string {
    17  	result := fmt.Sprintf("output.%s", n.Config.Name)
    18  	if len(n.PathValue) > 1 {
    19  		result = fmt.Sprintf("%s.%s", modulePrefixStr(n.PathValue), result)
    20  	}
    21  
    22  	return result
    23  }
    24  
    25  // GraphNodeSubPath
    26  func (n *NodeApplyableOutput) Path() []string {
    27  	return n.PathValue
    28  }
    29  
    30  // GraphNodeReferenceable
    31  func (n *NodeApplyableOutput) ReferenceableName() []string {
    32  	name := fmt.Sprintf("output.%s", n.Config.Name)
    33  	return []string{name}
    34  }
    35  
    36  // GraphNodeReferencer
    37  func (n *NodeApplyableOutput) References() []string {
    38  	var result []string
    39  	result = append(result, ReferencesFromConfig(n.Config.RawConfig)...)
    40  	for _, v := range result {
    41  		result = append(result, v+".destroy")
    42  	}
    43  
    44  	return result
    45  }
    46  
    47  // GraphNodeEvalable
    48  func (n *NodeApplyableOutput) EvalTree() EvalNode {
    49  	return &EvalOpFilter{
    50  		Ops: []walkOperation{walkRefresh, walkPlan, walkApply,
    51  			walkDestroy, walkInput, walkValidate},
    52  		Node: &EvalSequence{
    53  			Nodes: []EvalNode{
    54  				&EvalWriteOutput{
    55  					Name:      n.Config.Name,
    56  					Sensitive: n.Config.Sensitive,
    57  					Value:     n.Config.RawConfig,
    58  				},
    59  			},
    60  		},
    61  	}
    62  }