terraform: graph walk should handle eval errors properly
This commit is contained in:
parent
99eab4fd13
commit
e089e34c89
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue