opentofu/terraform/node_output_orphan.go
Mitchell Hashimoto 9890a2ee91
terraform: prune orphan outputs in old graph
This makes the old graph also prune orphan outputs in modules.
This will fix shadow graph errors such as #9905 since the old graph will
also behave correctly in these scenarios.

Luckily, because orphan outputs don't rely on anything, we were able to
simply use the same transformer!
2016-11-08 13:24:09 -08:00

36 lines
695 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
}
// 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,
},
}
}