diff --git a/pkg/templater/files.go b/pkg/templater/files.go index cc95268..c5428ab 100644 --- a/pkg/templater/files.go +++ b/pkg/templater/files.go @@ -133,20 +133,20 @@ func (cf *ConfigFile) processHCLTemplate(file string, config []byte) (string, er for n := range ctx.Variables { if !hclsyntax.ValidIdentifier(n) { - panic(fmt.Errorf("invalid template variable name %q: must start with a letter, followed by zero or more letters, digits, and underscores", n)) + return "", fmt.Errorf("invalid template variable name %q: must start with a letter, followed by zero or more letters, digits, and underscores", n) } } for _, traversal := range expr.Variables() { root := traversal.RootName() if _, ok := ctx.Variables[root]; !ok { - panic(fmt.Errorf("vars map does not contain key %q, referenced at %s", root, traversal[0].SourceRange())) + return "", fmt.Errorf("vars map does not contain key %q, referenced at %s", root, traversal[0].SourceRange()) } } val, diags := expr.Value(ctx) if diags.HasErrors() { - panic(diags.Error()) + return "", diags } return val.AsString(), nil