core: EvalConfigProvider shouldn't crash if its provider isn't set

While there's no good reason for this to happen in practice, it can arise
in tests if mocks aren't set up quite right, and so we'll catch it and
report it nicely to make test debugging a little easier.
This commit is contained in:
Martin Atkins 2018-05-04 19:46:17 -07:00
parent 7dacb6b6a8
commit 26c1584317
1 changed files with 7 additions and 0 deletions

View File

@ -36,6 +36,13 @@ type EvalConfigProvider struct {
}
func (n *EvalConfigProvider) Eval(ctx EvalContext) (interface{}, error) {
if n.Provider == nil {
return nil, fmt.Errorf("EvalConfigProvider Provider is nil")
}
if n.Config == nil {
return nil, nil
}
var diags tfdiags.Diagnostics
provider := *n.Provider
config := n.Config