Skip to content

Commit 833b074

Browse files
committed
template variables may be entirely unknown
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.
1 parent 31fdb1f commit 833b074

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

internal/lang/funcs/filesystem.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func MakeTemplateFileFunc(baseDir string, funcsCb func() (funcs map[string]funct
137137

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

140-
if !pathArg.IsKnown() {
140+
if !pathArg.IsKnown() || !vars.IsKnown() {
141141
return cty.UnknownVal(retType).WithMarks(pathMarks, varsMarks), nil
142142
}
143143

internal/lang/funcs/filesystem_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ func TestTemplateFile(t *testing.T) {
216216
cty.StringVal("- a\n- b\n- c\n").Mark("path").Mark("var"),
217217
``,
218218
},
219+
{
220+
cty.StringVal("testdata/list.tmpl").Mark("path"),
221+
cty.UnknownVal(cty.Map(cty.String)),
222+
cty.DynamicVal.Mark("path"),
223+
``,
224+
},
219225
{
220226
cty.StringVal("testdata/list.tmpl").Mark("path"),
221227
cty.ObjectVal(map[string]cty.Value{

0 commit comments

Comments
 (0)