feat: add support for YAML file includes and nested includes in context#1252
feat: add support for YAML file includes and nested includes in context#1252dandonovsc wants to merge 5 commits intoauth0:masterfrom
Conversation
|
Thank you for submitting this PR! Your contribution is greatly appreciated. We'll review it shortly |
… and nested includes
src/context/yaml/index.ts
Outdated
| ? wrapArrayReplaceMarkersInQuotes(fs.readFileSync(fPath, 'utf8'), this.mappings) | ||
| : keywordReplace(fs.readFileSync(fPath, 'utf8'), this.mappings) | ||
| ) || {} | ||
| resolveIncludes(loadedYaml, path.dirname(fPath), this.mappings, opts.disableKeywordReplacement) |
There was a problem hiding this comment.
Is it possible to use resolveIncludes before loadedYaml?
so that resolveIncludes can follow single responsibility.
There was a problem hiding this comment.
refactored the resolveIncludes function to follow the single responsibility principle. resolveIncludes() now handles the initial content parsing and delegates to resolveIncludesInObject()
resolveIncludesInObject() focuses solely on processing the parsed object structure
There was a problem hiding this comment.
Now, resolveIncludesInObject resolves includes, and also performs keywordReplace or wrapArrayReplaceMarkersInQuotes.
Ideally, one function resolveIncludes just to resolve YAML ! includes,
A better approach, I think.
Steps:
- resolveIncludes (full yaml)
- Depending on
opts.disableKeywordReplacement, should callwrapArrayReplaceMarkersInQuotesorkeywordReplace
let me know if it's possible to do it this way.
|
Thank you so much for your contribution! I’ve left a few small suggestions to help it align perfectly with our project. To keep our review queue organized, I’m moving this PR to Draft status while you work on these updates. |
…bility principle. resolveIncludes() now handles the initial content parsing and delegates to resolveIncludesInObject() resolveIncludesInObject() focuses solely on processing the parsed object structure
kushalshit27
left a comment
There was a problem hiding this comment.
Moving this PR to Draft status while you work on these updates. Thanks
🔧 Changes
Added YAML file include functionality to auth0-deploy-cli, allowing users to modularize their Auth0 configuration by splitting it into separate files and importing them using the !include directive.
New functionality:
Custom YAML type !include: Enables importing external YAML files within tenant configuration
resolveIncludes() function: Recursively processes YAML objects to resolve file includes with proper path resolution
Extended YAML schema: Modified the YAML context to support the new include syntax
Improved loadFile() method: Enhanced file path resolution with additional fallback mechanisms
This enables better organization of large Auth0 configurations by separating concerns into dedicated files while maintaining full compatibility with existing YAML functionality.
📚 References
This addresses the need for modular YAML configurations in auth0-deploy-cli, making it easier to manage complex Auth0 tenant setups by allowing configuration sections to be split across multiple files.
🔬 Testing
Automated tests added:
should process YAML with includes - Tests basic file inclusion functionality
should handle nested includes - Tests direct includes at root level
should error on missing include file - Tests error handling for missing files
Manual testing:
Create a main YAML file with !include directives
Create separate YAML files for each included section
Run a0deploy import -i tenant.yaml to verify includes are processed correctly
Verify that missing include files throw appropriate errors
Test coverage: All new functionality is covered by unit tests following existing patterns.