Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform: fail early if module validation fails #2479

Merged
merged 2 commits into from
Jun 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions terraform/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions terraform/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3132,28 +3132,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")
Expand Down