Merge pull request #2479 from hashicorp/b-validate-fail-early

terraform: fail early if module validation fails
This commit is contained in:
Mitchell Hashimoto 2015-06-25 17:50:35 -07:00
commit a3a2698e56
2 changed files with 6 additions and 22 deletions

View File

@ -434,6 +434,12 @@ func (c *Context) Validate() ([]string, []error) {
}
}
// If we have errors at this point, the graphing has no chance,
// so just bail early.
if errs != nil {
return nil, []error{errs}
}
// Build the graph so we can walk it and run Validate on nodes.
// We also validate the graph generated here, but this graph doesn't
// necessarily match the graph that Plan will generate, so we'll validate the

View File

@ -3112,28 +3112,6 @@ func TestContext2Validate_targetedDestroy(t *testing.T) {
}
}
func TestContext2Validate_varRef(t *testing.T) {
m := testModule(t, "validate-variable-ref")
p := testProvider("aws")
c := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
computed := false
p.ValidateResourceFn = func(t string, c *ResourceConfig) ([]string, []error) {
computed = c.IsComputed("foo")
return nil, nil
}
c.Validate()
if !computed {
t.Fatal("should be computed")
}
}
func TestContext2Validate_varRefFilled(t *testing.T) {
m := testModule(t, "validate-variable-ref")
p := testProvider("aws")