feat: support recursive HCL vars and env references #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Testing
go test ./...Prompt
Task 9: Recursive Resolution Support for HCL Variables
Purpose:
Enable recursive and referential evaluation of HCL expressions in
varsandenv, such that later values can refer to previously declared values, including through expression functions. This allows building rich, composable configurations similar to Terraform or Docker Bake.Requirements:
vars.Xandenv.Xkeys."Hello, ${vars.NAME}") and function composition (upper(vars.GREETING)).NAME = "${vars.NAME}").Scope:
varsandenvblocks.Implementation Hints (Do Not Copy Code):
hcl.Expressionduring parsing.EvalContext) must resolve values on-demand.Validation:
Unit test with:
Assert:
GREETING == "Hello, BOB!"UPPER_GREETING == "HELLO, BOB!"Test ordering independence:
Assert:
FINAL == "YUP + OK"Test invalid cyclic reference:
Should fail with error indicating cyclic variable reference.
Extend
HCLE2ETestto include realistic example that uses multiple layers of recursive expression resolution.By completing this task, the HCL loader and runtime will fully support dynamic configuration patterns, improving flexibility and parity with advanced DSLs like Terraform.
https://chatgpt.com/codex/tasks/task_e_68922f2b906483309838d8c558bc399a