Skip to content

Commit

Permalink
template variables may be entirely unknown
Browse files Browse the repository at this point in the history
While the evaluator can deal with unknown template variables, if the
entire map of variables is unknown, we can't create the map and need to
short-circuit the call.
  • Loading branch information
jbardin committed Nov 27, 2024
1 parent 31fdb1f commit 833b074
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/lang/funcs/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func MakeTemplateFileFunc(baseDir string, funcsCb func() (funcs map[string]funct

vars, varsMarks := args[1].UnmarkDeep()

if !pathArg.IsKnown() {
if !pathArg.IsKnown() || !vars.IsKnown() {
return cty.UnknownVal(retType).WithMarks(pathMarks, varsMarks), nil
}

Expand Down
6 changes: 6 additions & 0 deletions internal/lang/funcs/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ func TestTemplateFile(t *testing.T) {
cty.StringVal("- a\n- b\n- c\n").Mark("path").Mark("var"),
``,
},
{
cty.StringVal("testdata/list.tmpl").Mark("path"),
cty.UnknownVal(cty.Map(cty.String)),
cty.DynamicVal.Mark("path"),
``,
},
{
cty.StringVal("testdata/list.tmpl").Mark("path"),
cty.ObjectVal(map[string]cty.Value{
Expand Down

0 comments on commit 833b074

Please sign in to comment.