Skip to content

Commit 5ccb3c7

Browse files
committed
templatefile need to be unmarked for TypeFunc
The templatefile function actually calls the full renderer within the TypeFunc to determine what the resulting might be, but that also requires unmarking the top-level of the vars map to strip marks even though the value is unused.
1 parent a1b4643 commit 5ccb3c7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

internal/lang/funcs/filesystem.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ func MakeTemplateFileFunc(baseDir string, funcsCb func() (funcs map[string]funct
126126
if err != nil {
127127
return cty.DynamicPseudoType, err
128128
}
129+
vars, _ := args[1].UnmarkDeep()
129130

130131
// This is safe even if args[1] contains unknowns because the HCL
131132
// template renderer itself knows how to short-circuit those.
132-
val, err := renderTmpl(expr, args[1])
133+
val, err := renderTmpl(expr, vars)
133134
return val.Type(), err
134135
},
135136
Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {

internal/lang/funcs/filesystem_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ func TestTemplateFile(t *testing.T) {
211211
cty.StringVal("a"),
212212
cty.StringVal("b").Mark("var"),
213213
cty.StringVal("c"),
214-
}),
214+
}).Mark("vars"),
215215
}),
216-
cty.StringVal("- a\n- b\n- c\n").Mark("path").Mark("var"),
216+
cty.StringVal("- a\n- b\n- c\n").Mark("path").Mark("var").Mark("vars"),
217217
``,
218218
},
219219
{

0 commit comments

Comments
 (0)