mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
9890a2ee91
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!
36 lines
695 B
Go
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,
|
|
},
|
|
}
|
|
}
|