From 941e27b9f3d09a1e77984b5b79c3cfd38ad90b67 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 2 Oct 2014 13:24:38 -0700 Subject: [PATCH] terraform: Validate expands properly --- terraform/context.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/terraform/context.go b/terraform/context.go index 34505e3cf..a8894a73f 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -956,7 +956,8 @@ func (c *walkContext) validateWalkFn() depgraph.WalkFunc { meta.Children = make(map[string]*walkValidateMeta) } - return func(n *depgraph.Noun) error { + var walkFn depgraph.WalkFunc + walkFn = func(n *depgraph.Noun) error { // If it is the root node, ignore if n.Name == GraphRootNode { return nil @@ -988,6 +989,11 @@ func (c *walkContext) validateWalkFn() depgraph.WalkFunc { panic("resource should never be nil") } + // If we're expanding, then expand the nodes, and then rewalk the graph + if rn.ExpandMode > ResourceExpandNone { + return c.genericWalkResource(rn, walkFn) + } + // If it doesn't have a provider, that is a different problem if rn.Resource.Provider == nil { return nil @@ -1060,6 +1066,8 @@ func (c *walkContext) validateWalkFn() depgraph.WalkFunc { return nil } + + return walkFn } func (c *walkContext) genericWalkFn(cb genericWalkFunc) depgraph.WalkFunc {