tofusoup 2025-05-31
Initial CLI tool with Go and Python generators for cross-language cty testing
20 files · 1,542+ · 1,183-

CLI framework and command structure

2 files changed
  • cli.py Click-based CLI with build-go, generate, and convert subcommands; async subprocess runner for Go binary
  • pyproject.toml Project metadata and dependencies including click, msgpack, python-hcl2, pyyaml
  • Established main CLI entry point with verbose/log-file options and version display instantiate architectural
    1 file
    • cli.py
  • Added build-go command to compile Go cty generator via build_go.sh instantiate behavioral
    1 file
    • cli.py
  • Added generate command supporting both Go and Python implementations with YAML input and JSON/Msgpack output instantiate behavioral
    1 file
    • cli.py

Go cty value generator

1 file changed
  • go_cty_generator.go Go utility that parses cty type definitions, constructs cty.Values from YAML input, and serializes to JSON or Msgpack
  • Implemented type definition parser supporting string, number, bool, list, set, map, tuple, and object types instantiate behavioral
    1 file
    • go_cty_generator.go
  • Added nested delimiter-respecting parser for complex type strings like object({name=string,age=number}) instantiate behavioral
    1 file
    • go_cty_generator.go
  • Added emoji-based structured logging with domain/action/status prefix system instantiate internal
    1 file
    • go_cty_generator.go

Python cty generator and conversion logic

4 files changed
  • py_cty_generator.py Python-side cty value generation for cross-language comparison
  • convert_logic.py File format conversion between HCL, JSON, and Msgpack using Python dictionaries as intermediate representation
  • go_interaction.py Async subprocess wrapper for invoking the Go cty generator binary
  • utils.py Shared utility functions including YAML spec parsing
  • Implemented loaders for HCL (python-hcl2), JSON, and Msgpack formats with ConversionError handling instantiate behavioral
    1 file
    • convert_logic.py
  • HCL output (dump_dict_to_hcl_string) left as NotImplementedError due to python-hcl2 lacking a dumps equivalent specify behavioral
    1 file
    • convert_logic.py

Test infrastructure and design documentation

4 files changed
  • test_cli_commands.py CLI integration tests covering build, generate, and convert commands
  • test_convert_commands.py Conversion-specific tests for HCL/JSON/Msgpack round-trips
  • test_cty_compatibility.py Cross-language compatibility test suite comparing Go and Python cty outputs
  • CONVERT_COMMAND_DESIGN.md Design doc for the convert file command with future CtyValue-centric refactor plan
  • Added test cases for CLI invocation, format conversion, and error handling qualify behavioral
    2 files
    • test_cli_commands.py
    • test_convert_commands.py

Terraform example fixtures

6 files changed
  • simple_for_hcl_view.tf Simple Terraform config for HCL viewing tests
  • simple_for_convert.json JSON fixture for conversion tests
  • simple_resource_for_convert.tf Terraform resource fixture for convert tests
  • complex_for_hcl_view.tf Complex nested Terraform config for HCL view testing
  • invalid_for_convert.tf Invalid Terraform file for error-path testing
  • invalid_for_hcl_view.tf Invalid HCL file for error-path testing
  • Added diverse Terraform and JSON fixtures for testing format detection and conversion qualify internal
    3 files
    • simple_for_hcl_view.tf
    • simple_for_convert.json
    • simple_resource_for_convert.tf