opentofu/terraform/node_output_orphan.go
James Bardin e3ea3150ae make NodeOutputOrphan referenceable
The removed output need to be referencable so if its parent module is
also being remove, the removal happens in the correct order.
2017-11-09 10:52:46 -05:00

41 lines
825 B
Go

package terraform
import (
"fmt"
)
// NodeOutputOrphan represents an output that is an orphan.
type NodeOutputOrphan struct {
OutputName string
PathValue []string
}
func (n *NodeOutputOrphan) Name() string {
result := fmt.Sprintf("output.%s (orphan)", n.OutputName)
if len(n.PathValue) > 1 {
result = fmt.Sprintf("%s.%s", modulePrefixStr(n.PathValue), result)
}
return result
}
// GraphNodeReferenceable
func (n *NodeOutputOrphan) ReferenceableName() []string {
return []string{"output." + n.OutputName}
}
// GraphNodeSubPath
func (n *NodeOutputOrphan) Path() []string {
return n.PathValue
}
// GraphNodeEvalable
func (n *NodeOutputOrphan) EvalTree() EvalNode {
return &EvalOpFilter{
Ops: []walkOperation{walkRefresh, walkApply, walkDestroy},
Node: &EvalDeleteOutput{
Name: n.OutputName,
},
}
}