1package terraform
2
3import (
4	"fmt"
5
6	"github.com/hashicorp/terraform/addrs"
7)
8
9// NodeOutputOrphan represents an output that is an orphan.
10type NodeOutputOrphan struct {
11	Addr addrs.AbsOutputValue
12}
13
14var (
15	_ GraphNodeSubPath          = (*NodeOutputOrphan)(nil)
16	_ GraphNodeReferenceable    = (*NodeOutputOrphan)(nil)
17	_ GraphNodeReferenceOutside = (*NodeOutputOrphan)(nil)
18	_ GraphNodeEvalable         = (*NodeOutputOrphan)(nil)
19)
20
21func (n *NodeOutputOrphan) Name() string {
22	return fmt.Sprintf("%s (orphan)", n.Addr.String())
23}
24
25// GraphNodeReferenceOutside implementation
26func (n *NodeOutputOrphan) ReferenceOutside() (selfPath, referencePath addrs.ModuleInstance) {
27	return referenceOutsideForOutput(n.Addr)
28}
29
30// GraphNodeReferenceable
31func (n *NodeOutputOrphan) ReferenceableAddrs() []addrs.Referenceable {
32	return referenceableAddrsForOutput(n.Addr)
33}
34
35// GraphNodeSubPath
36func (n *NodeOutputOrphan) Path() addrs.ModuleInstance {
37	return n.Addr.Module
38}
39
40// GraphNodeEvalable
41func (n *NodeOutputOrphan) EvalTree() EvalNode {
42	return &EvalOpFilter{
43		Ops: []walkOperation{walkRefresh, walkApply, walkDestroy},
44		Node: &EvalDeleteOutput{
45			Addr: n.Addr.OutputValue,
46		},
47	}
48}
49