Try 07
This commit is contained in:
parent
e47d2f64df
commit
d10e0e1194
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue