🔧 Support multiple --mappings-file flags with deep merge capability#67
Merged
🔧 Support multiple --mappings-file flags with deep merge capability#67
Conversation
- Modified GenerateCommand to accept multiple --mappings-file arguments using action='append' - Added _deep_merge_dicts method for intelligent merging of mapping files - Later files override earlier ones for conflicting keys, with deep merging for nested dicts - Updated documentation to explain merging behavior and provide examples - Added comprehensive tests for deep merge functionality and multiple mappings file handling Resolves #66
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67 +/- ##
==========================================
+ Coverage 65.33% 66.47% +1.14%
==========================================
Files 22 22
Lines 1203 1238 +35
Branches 171 174 +3
==========================================
+ Hits 786 823 +37
+ Misses 378 376 -2
Partials 39 39 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🧩 Feature Implementation
This PR implements support for multiple
--mappings-fileflags as requested in issue #66.✅ What Changed
Core Functionality
--mappings-fileflags usingaction='append'_deep_merge_dicts()method for intelligent mergingUsage Examples
Basic multiple mappings:
struct generate \ --mappings-file ./common-mappings.yaml \ --mappings-file ./env-specific-mappings.yaml \ file://my-struct.yaml .Environment-based automation:
struct generate \ --mappings-file ./mappings/common.yaml \ --mappings-file ./mappings/${ENVIRONMENT}.yaml \ file://infrastructure.yaml \ ./outputMerging Behavior
Input files:
common.yaml:production.yaml:Merged result:
🛠️ Technical Implementation
Deep Merge Algorithm
Error Handling
Backward Compatibility
--mappings-fileusage remains unchanged📚 Documentation Updates
🧪 Testing
Added comprehensive tests covering:
🚀 Benefits
For CI/CD Automation
For DRY Principles
For Complex Projects
🔗 Resolves
Closes #66
This implementation provides the exact functionality requested in the issue while maintaining backward compatibility and adding comprehensive documentation and testing.