Skip to content

Commit 294c7eb

Browse files
kklimonda-clkklimonda
authored andcommitted
refactor(codegen): Split large files in pkg/translate/ for improved maintainability
Split three oversized files into 17 focused modules to improve code organization and maintainability. This is a pure refactoring with zero behavioral changes, verified by test-harness showing identical generated code. Changes: - Split terraform_provider/funcs.go (3,428 lines) → 9 files: * encryption.go - Encrypted value handling * conversion.go - Terraform/Pango data conversion * location.go - Location struct and schema generation * schema.go - Terraform schema generation * import_state.go - Import state handling * structs_model.go - Terraform model struct generation * crud_operations.go - CRUD operations (Create/Read/Update/Delete) * ephemeral_operations.go - Ephemeral resource operations * utils.go - Shared utilities - Split structs.go (1,029 lines) → 5 files: * template_utils.go - Template loading utilities * import_location.go - Import and location rendering * type_calculation.go - Type and tag calculation * struct_generation.go - Struct creation and rendering * xml_marshaling.go - XML marshaling and containers - Split terraform_provider/terraform_provider_file.go (713 lines) → 3 files: * generator.go - Core generator orchestration * entity_generators.go - Entity-specific generation * provider_generators.go - Provider-level generation Metrics: - Largest file reduced from 3,428 to 471 lines (86% reduction) - All files now under 750 lines - Average file size: ~250 lines - Zero files over 500 lines (previously 3) Verification: - All tests pass (make test/codegen) - Generated code identical to baseline (codegen-diff) - No circular dependencies - No compilation errors This refactoring improves code navigability, makes reviews easier, and reduces cognitive load by organizing code into single-responsibility modules.
1 parent 8c1badb commit 294c7eb

0 file changed

File tree

    0 commit comments

    Comments
     (0)