From 26c158431729301f6f8cad335fad1d1307c4d5de Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Fri, 4 May 2018 19:46:17 -0700 Subject: [PATCH] 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. --- terraform/eval_provider.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/terraform/eval_provider.go b/terraform/eval_provider.go index b0d46ea4f..a374fbc15 100644 --- a/terraform/eval_provider.go +++ b/terraform/eval_provider.go @@ -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