LogoCyanPrint
ResolversExplanation

Resolvers in Pipeline

How resolvers fit into the template generation pipeline

Resolvers in Pipeline

Resolvers are the third step in the template generation pipeline, after processors but before plugins.

Pipeline Overview

Execution Order

1. Template Execution

  • Template collects user input
  • Template defines files and configuration
  • Template specifies processors, resolvers, and plugins

2. Processor Execution

  • Processors transform individual files
  • Applied to all files matching globs
  • Outputs transformed files

3. Resolver Execution

This is where resolvers run.

  • Receives multiple versions of conflicting files
  • Applies merge logic based on configuration
  • Outputs single merged file per conflict

4. Plugin Execution

  • Runs after all files are generated
  • Can run commands, modify files
  • Returns final directory

When Resolvers Execute

Resolvers execute when:

  • Multiple templates provide the same file path
  • Template composition creates file overlaps
  • Explicit resolver configuration in cyan.yaml

If only one file version exists for a path, the resolver may still be called but simply returns that single version.

Resolver Configuration

Templates configure resolvers in cyan.yaml:

cyan.yaml
resolvers:
- resolver: org/json-merger:1
config:
arrayStrategy: concat
deepMerge: true
files:
- config.json
- package.json
- "*.json"

Configuration Options

OptionDescriptionExample
resolverResolver image referenceorg/json-merger:1
configConfiguration passed to resolverarrayStrategy: concat
filesFile patterns to resolve["*.json"]

Data Flow

Input to Resolver

{
"config": {
"arrayStrategy": "concat"
},
"files": [
{
"path": "config.json",
"content": "{\"name\": \"app\"}",
"origin": {
"template": "base-template",
"layer": 0
}
},
{
"path": "config.json",
"content": "{\"version\": \"1.0\"}",
"origin": {
"template": "feature-template",
"layer": 1
}
}
]
}

Output from Resolver

{
"path": "config.json",
"content": "{\"name\": \"app\", \"version\": \"1.0\"}"
}

Error Handling

Resolvers should:

  • Validate input - Check file paths match
  • Handle edge cases - Empty files, missing content
  • Report errors - Throw meaningful exceptions

Common Errors

ErrorCauseSolution
Path mismatchFiles have different pathsEnsure resolver configured for correct files
Invalid JSONContent is not valid JSONAdd JSON validation
Missing configRequired config not providedAdd default values
Merge conflictUnable to merge contentDefine conflict resolution strategy

Performance Considerations

  • File size - Large files may need streaming
  • Memory usage - Be mindful of memory when merging many files
  • Timeout - Complex merges may need more time

Resolvers have a 10-minute timeout by default. If your merge operation takes longer, consider optimizing the logic.

Next Steps