diff --git a/terraform/graph.go b/terraform/graph.go index f6cce7375..cf931fb1f 100644 --- a/terraform/graph.go +++ b/terraform/graph.go @@ -156,7 +156,9 @@ func (g *Graph) walk(walker GraphWalker) error { log.Printf("[DEBUG] vertex %s.%s: evaluating", path, dag.VertexName(v)) tree = walker.EnterEvalTree(v, tree) output, err := Eval(tree, ctx) - walker.ExitEvalTree(v, output, err) + if rerr = walker.ExitEvalTree(v, output, err); rerr != nil { + return + } } // If the node is dynamically expanded, then expand it diff --git a/terraform/graph_walk.go b/terraform/graph_walk.go index 13b169559..f5da6c093 100644 --- a/terraform/graph_walk.go +++ b/terraform/graph_walk.go @@ -12,7 +12,7 @@ type GraphWalker interface { EnterVertex(dag.Vertex) ExitVertex(dag.Vertex, error) EnterEvalTree(dag.Vertex, EvalNode) EvalNode - ExitEvalTree(dag.Vertex, interface{}, error) + ExitEvalTree(dag.Vertex, interface{}, error) error } // NullGraphWalker is a GraphWalker implementation that does nothing. @@ -25,4 +25,6 @@ func (NullGraphWalker) ExitGraph(*Graph) {} func (NullGraphWalker) EnterVertex(dag.Vertex) {} func (NullGraphWalker) ExitVertex(dag.Vertex, error) {} func (NullGraphWalker) EnterEvalTree(v dag.Vertex, n EvalNode) EvalNode { return n } -func (NullGraphWalker) ExitEvalTree(dag.Vertex, interface{}, error) {} +func (NullGraphWalker) ExitEvalTree(dag.Vertex, interface{}, error) error { + return nil +} diff --git a/terraform/graph_walk_context.go b/terraform/graph_walk_context.go index b27387aef..f8cc81086 100644 --- a/terraform/graph_walk_context.go +++ b/terraform/graph_walk_context.go @@ -3,7 +3,6 @@ package terraform import ( "sync" - "github.com/hashicorp/go-multierror" "github.com/hashicorp/terraform/dag" ) @@ -18,7 +17,6 @@ type ContextGraphWalker struct { // Outputs, do not set these. Do not read these while the graph // is being walked. - EvalError error Diff *Diff ValidationWarnings []string ValidationErrors []error @@ -90,9 +88,9 @@ func (w *ContextGraphWalker) EnterEvalTree(v dag.Vertex, n EvalNode) EvalNode { } func (w *ContextGraphWalker) ExitEvalTree( - v dag.Vertex, output interface{}, err error) { + v dag.Vertex, output interface{}, err error) error { if err == nil { - return + return nil } // Acquire the lock because anything is going to require a lock. @@ -103,14 +101,13 @@ func (w *ContextGraphWalker) ExitEvalTree( // error, then just record the normal error. verr, ok := err.(*EvalValidateError) if !ok { - // Some other error, record it - w.EvalError = multierror.Append(w.EvalError, err) - return + return err } // Record the validation error w.ValidationWarnings = append(w.ValidationWarnings, verr.Warnings...) w.ValidationErrors = append(w.ValidationErrors, verr.Errors...) + return nil } func (w *ContextGraphWalker) init() {