make NodePlannableResource eval-able
Eval a NodePlannableResource before expanding it, to ensure that it can be referenced even if the count is 0.
This commit is contained in:
parent
ae8f7bf434
commit
8130948936
|
@ -1,6 +1,8 @@
|
||||||
package terraform
|
package terraform
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/dag"
|
"github.com/hashicorp/terraform/dag"
|
||||||
"github.com/hashicorp/terraform/tfdiags"
|
"github.com/hashicorp/terraform/tfdiags"
|
||||||
)
|
)
|
||||||
|
@ -20,6 +22,25 @@ var (
|
||||||
_ GraphNodeAttachResourceConfig = (*NodePlannableResource)(nil)
|
_ GraphNodeAttachResourceConfig = (*NodePlannableResource)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GraphNodeEvalable
|
||||||
|
func (n *NodePlannableResource) EvalTree() EvalNode {
|
||||||
|
addr := n.ResourceAddr()
|
||||||
|
config := n.Config
|
||||||
|
|
||||||
|
if config == nil {
|
||||||
|
// Nothing to do, then.
|
||||||
|
log.Printf("[TRACE] NodeApplyableResource: no configuration present for %s", addr)
|
||||||
|
return &EvalNoop{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// this ensures we can reference the resource even if the count is 0
|
||||||
|
return &EvalWriteResourceState{
|
||||||
|
Addr: addr.Resource,
|
||||||
|
Config: config,
|
||||||
|
ProviderAddr: n.ResolvedProvider,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// GraphNodeDynamicExpandable
|
// GraphNodeDynamicExpandable
|
||||||
func (n *NodePlannableResource) DynamicExpand(ctx EvalContext) (*Graph, error) {
|
func (n *NodePlannableResource) DynamicExpand(ctx EvalContext) (*Graph, error) {
|
||||||
var diags tfdiags.Diagnostics
|
var diags tfdiags.Diagnostics
|
||||||
|
|
Loading…
Reference in New Issue