Skip to content

Commit

Permalink
Merge pull request #36118 from hashicorp/jbardin/unknown-template-vars
Browse files Browse the repository at this point in the history
template variables may be entirely unknown
  • Loading branch information
jbardin authored Nov 27, 2024
2 parents 3d0756f + 833b074 commit a1b4643
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 a1b4643

Please sign in to comment.