Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive file embedding support to the cfgx tool, allowing TOML values to reference external files using the file: prefix syntax. When generation occurs, these files are read and embedded as []byte arrays in the generated Go code, creating self-contained binaries.
Key changes:
- File embedding using
file:path/to/filesyntax in TOML values - Configurable size limits with
--max-file-sizeflag (default 1MB) - Code refactoring to split
generator.gointo focused modules
Reviewed Changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| readme.md | Added comprehensive documentation for file embedding feature with examples and use cases |
| internal/generator/generator.go | Refactored to move most functionality to focused modules, added file validation support |
| internal/generator/file_handler.go | New module handling file reference detection and content loading with size validation |
| internal/generator/value_writer.go | New module for Go value serialization with file embedding and duration support |
| internal/generator/struct_gen.go | New module containing struct generation logic moved from main generator |
| internal/generator/validation.go | New module for validation helpers including time import detection |
| cmd/cfgx/main.go | Added --max-file-size flag with human-readable size parsing |
| cfgx.go | Updated public API to support file embedding with new options |
| testdata/files/ | Added test files for validating file embedding functionality |
| example/config/ | Updated example to demonstrate file embedding with certificate |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
📊 Code Coverage ReportCoverage by file |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 19 out of 20 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
internal/generator/value_writer.go:1
- The writeValueWithIndent call should use the correct value parameter - it's passing 'value' instead of 'val' which is the []any slice being processed.
package generator
internal/generator/value_writer.go:1
- The writeValueWithIndent call should use the correct value parameter - it's passing 'value' instead of 'val' which is the []any slice being processed.
package generator
internal/generator/value_writer.go:1
- Type mismatch: writeArrayOfStructs expects []any or []map[string]any, but val is []map[string]any. The function should be called with the correct type.
package generator
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Add file embedding support
This PR adds the ability to embed file contents directly into generated Go code using the
file:prefix in TOML values.Features
file:path/to/filein TOML to embed file contents as[]bytein generated code--max-file-sizeflagRefactoring
generator.gointo focused modules:file_handler.go- file reading and embeddingstruct_gen.go- struct generation logicvalidation.go- validation helpersvalue_writer.go- value serializationUse Cases
Files are embedded as hex byte arrays at generation time, making binaries self-contained with no runtime I/O needed.