Skip to content

feat(provisioner/terraform/tfparse): implement WorkspaceTagDefaultsFromFile #15236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 14, 2024
Merged
Prev Previous commit
Next Next commit
clarify lack of function support
  • Loading branch information
johnstcn committed Nov 11, 2024
commit ad2d3a926c442a6847838c19d5b99fa428535288
5 changes: 5 additions & 0 deletions provisioner/terraform/tfparse/tfextract.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@ func buildEvalContext(varDefaults map[string]string, paramDefaults map[string]st

evalCtx := &hcl.EvalContext{
Variables: map[string]cty.Value{},
// NOTE: we do not currently support function execution here.
// The default function map for Terraform is not exposed, so we would essentially
// have to re-implement or copy the entire map or a subset thereof.
// ref: https://github.com/hashicorp/terraform/blob/e044e569c5bc81f82e9a4d7891f37c6fbb0a8a10/internal/lang/functions.go#L54
Functions: nil,
}
if len(varDefaultsM) != 0 {
evalCtx.Variables["var"] = cty.MapVal(varDefaultsM)
Expand Down
4 changes: 2 additions & 2 deletions provisioner/terraform/tfparse/tfparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ func Test_WorkspaceTagDefaultsFromFile(t *testing.T) {
}
}`,
},
expectTags: map[string]string{"platform": "kubernetes", "cluster": "developers", "region": "us", "az": "a"},
expectError: ``,
expectTags: nil,
expectError: `Function calls not allowed; Functions may not be called here.`,
},
} {
tc := tc
Expand Down