terraform: fix potential nil access on graph

This commit is contained in:
Mitchell Hashimoto 2014-07-07 15:21:46 -07:00
parent 65d959003f
commit b80e8364d0
1 changed files with 9 additions and 7 deletions

View File

@ -241,13 +241,15 @@ func (c *Context) Validate() ([]string, []error) {
// Walk the graph and validate all the configs
var warns []string
var errs []error
err = g.Walk(c.validateWalkFn(&warns, &errs))
if err != nil {
rerr = multierror.ErrorAppend(rerr, fmt.Errorf(
"Error validating resources in graph: %s", err))
}
if len(errs) > 0 {
rerr = multierror.ErrorAppend(rerr, errs...)
if g != nil {
err = g.Walk(c.validateWalkFn(&warns, &errs))
if err != nil {
rerr = multierror.ErrorAppend(rerr, fmt.Errorf(
"Error validating resources in graph: %s", err))
}
if len(errs) > 0 {
rerr = multierror.ErrorAppend(rerr, errs...)
}
}
errs = nil