opentofu/terraform/node_output_orphan.go
James Bardin 40f09027f0 expand planned resources
While the Expander itself now handles the recursive expansion of
modules, Resources themselves still need to be expanded twice, because
the evaluation of the Resource, which entails evaluating the for_each or
count expressions, is separate from the ResourceInstance expansion.

Add a nodeExpandPlannableResource to do handle this expansion to allow
all NodePlannableResources to call EvalWriteResourceState with an
absolute address.
2020-03-25 17:03:06 -04:00

54 lines
1.3 KiB
Go

package terraform
import (
"fmt"
"github.com/hashicorp/terraform/addrs"
)
// NodeOutputOrphan represents an output that is an orphan.
type NodeOutputOrphan struct {
Addr addrs.AbsOutputValue
}
var (
_ GraphNodeModuleInstance = (*NodeOutputOrphan)(nil)
_ GraphNodeReferenceable = (*NodeOutputOrphan)(nil)
_ GraphNodeReferenceOutside = (*NodeOutputOrphan)(nil)
_ GraphNodeEvalable = (*NodeOutputOrphan)(nil)
)
func (n *NodeOutputOrphan) Name() string {
return fmt.Sprintf("%s (orphan)", n.Addr.String())
}
// GraphNodeReferenceOutside implementation
func (n *NodeOutputOrphan) ReferenceOutside() (selfPath, referencePath addrs.Module) {
return referenceOutsideForOutput(n.Addr)
}
// GraphNodeReferenceable
func (n *NodeOutputOrphan) ReferenceableAddrs() []addrs.Referenceable {
return referenceableAddrsForOutput(n.Addr)
}
// GraphNodeModuleInstance
func (n *NodeOutputOrphan) Path() addrs.ModuleInstance {
return n.Addr.Module
}
// GraphNodeModulePath
func (n *NodeOutputOrphan) ModulePath() addrs.Module {
return n.Addr.Module.Module()
}
// GraphNodeEvalable
func (n *NodeOutputOrphan) EvalTree() EvalNode {
return &EvalOpFilter{
Ops: []walkOperation{walkRefresh, walkApply, walkDestroy},
Node: &EvalDeleteOutput{
Addr: n.Addr,
},
}
}