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:
James Bardin 2018-09-19 21:30:16 -04:00 committed by Martin Atkins
parent ae8f7bf434
commit 8130948936
1 changed files with 21 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package terraform
import (
"log"
"github.com/hashicorp/terraform/dag"
"github.com/hashicorp/terraform/tfdiags"
)
@ -20,6 +22,25 @@ var (
_ 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
func (n *NodePlannableResource) DynamicExpand(ctx EvalContext) (*Graph, error) {
var diags tfdiags.Diagnostics