github.com/r3labs/terraform@v0.8.4/terraform/node_output.go (about)

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