Skip to content

Commit

Permalink
don't dump template string in errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Thierno IB. BARRY committed May 17, 2020
1 parent 615ea78 commit 239fc1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lang/funcs/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func MakeTemplateFunc(funcsCb func() map[string]function.Function) function.Func
}

loadTmpl := func(fn string) (hcl.Expression, error) {
expr, diags := hclsyntax.ParseTemplate([]byte(fn), fn, hcl.Pos{Line: 1, Column: 1})
expr, diags := hclsyntax.ParseTemplate([]byte(fn), params[0].Name, hcl.Pos{Line: 1, Column: 1})
if diags.HasErrors() {
return nil, diags
}
Expand Down
6 changes: 3 additions & 3 deletions lang/funcs/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestTemplate(t *testing.T) {
cty.StringVal("Hello, ${name}!"),
cty.EmptyObjectVal,
cty.NilVal,
`vars map does not contain key "name", referenced at Hello, ${name}!:1,10-14`,
`vars map does not contain key "name", referenced at str:1,10-14`,
},
{
cty.StringVal(""),
Expand Down Expand Up @@ -135,7 +135,7 @@ func TestTemplate(t *testing.T) {
cty.StringVal("Hello, ${template(\"\",{})}!"),
cty.MapValEmpty(cty.String),
cty.NilVal,
`Hello, ${template("",{})}!:1,10-19: Error in function call; Call to function "template" failed: cannot recursively call template from inside template call.`,
`str:1,10-19: Error in function call; Call to function "template" failed: cannot recursively call template from inside template call.`,
},
{
cty.StringVal("%{ for x in list ~}\n- ${x}\n%{ endfor ~}"),
Expand All @@ -155,7 +155,7 @@ func TestTemplate(t *testing.T) {
"list": cty.True,
}),
cty.NilVal,
"%{ for x in list ~}\n- ${x}\n%{ endfor ~}:1,13-17: Iteration over non-iterable value; A value of type bool cannot be used as the collection in a 'for' expression.",
`str:1,13-17: Iteration over non-iterable value; A value of type bool cannot be used as the collection in a 'for' expression.`,
},
{
cty.StringVal("${val}"),
Expand Down

0 comments on commit 239fc1e

Please sign in to comment.