Skip to content

Conversation

@dandonovsc
Copy link

🔧 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

# tenant.yaml
tenant:
  friendly_name: 'My Tenant'

clients: !include clients.yaml
roles: !include roles.yaml

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.

@dandonovsc dandonovsc requested a review from a team as a code owner January 2, 2026 22:02
@kushalshit27
Copy link
Contributor

Thank you for submitting this PR! Your contribution is greatly appreciated. We'll review it shortly

? wrapArrayReplaceMarkersInQuotes(fs.readFileSync(fPath, 'utf8'), this.mappings)
: keywordReplace(fs.readFileSync(fPath, 'utf8'), this.mappings)
) || {}
resolveIncludes(loadedYaml, path.dirname(fPath), this.mappings, opts.disableKeywordReplacement)
Copy link
Contributor

@kushalshit27 kushalshit27 Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use resolveIncludes before loadedYaml?

so that resolveIncludes can follow single responsibility.

const schema = yaml.DEFAULT_SCHEMA.extend([includeType]);

// Function to resolve includes
function resolveIncludes(obj, basePath, mappings?: KeywordMappings, disableKeywordReplacement?: boolean) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolveIncludes recursively processes includes without cycle detection. If a YAML file directly or indirectly includes itself (e.g., a.yaml → b.yaml → a.yaml), this results in unbounded recursion and can crash the CLI with a stack overflow rather than surfacing a clear error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants