Skip to content

Fix Terraform object attributes in HCL round trips - #66

Merged
JFryy merged 3 commits into
mainfrom
fix/hcl-object-attributes
Oct 1, 2026
Merged

JFryy merged 3 commits into
mainfrom
fix/hcl-object-attributes

Conversation

@JFryy

@JFryy JFryy commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Closes #60

Fix Terraform/HCL round trips: preserve object attributes, reconstruct labeled and repeated blocks, and keep references and expressions executable instead of turning them into literal strings. Templates, escaped literal markers, and expressions inside objects/lists follow hcl2json's encoding. Preserve timestamps and numeric types from other codecs, and reject malformed expressions.

Tests now evaluate the original and rewritten tests/test.tf with the same variables and compare attribute values/types and block structure. The fixture includes repeated filters. Additional coverage includes conditionals, function calls, templates, computed keys, escaped literals, and the TOML/MessagePack conversions that previously failed CI.

Plain JSON still cannot distinguish object-list attributes from repeated blocks without a schema; the writer follows hcl2json's block convention. Formatting and comments are not preserved.

@JFryy
JFryy merged commit 5c16645 into main Oct 1, 2026
1 check passed
@JFryy
JFryy deleted the fix/hcl-object-attributes branch October 1, 2026 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cannot go from tf to json and back to tf

1 participant