LogoCyanPrint
Processors

Processor Development

Create custom file transformers for CyanPrint templates

Processor Development

Processors are the transformation engines that convert template files into generated output. The default processor uses Eta templating, but you can create custom processors for any transformation needs.

What is a Processor?

A processor is a Docker container that:

  1. Receives files from the template's blob image
  2. Transforms content based on configuration
  3. Outputs files to the write directory

Processors are stateless file transformers - they receive input files and produce output files without side effects.

Processor Architecture

Components

ComponentPurposeExamples
Entry PointProcessor logicStartProcessorWithLambda
CyanFileHelperFile operationsresolveAll(), read(), copy()
CyanProcessorInputInput from templateConfig, globs, directories
ProcessorOutputReturn valueOutput directory path

Why Create a Custom Processor?

Different Templating Engines

The default processor uses Eta with var__name__ syntax. You might need:

EngineUse Case
JinjaPython-style templates
Go templatesHelm/Kubernetes manifests
MustacheLogic-less templates
HandlebarsRich template features

Custom Logic

Processors enable custom processing that goes beyond simple variable substitution:

  • Code generation (GraphQL, Protobuf, OpenAPI)
  • AST transformations
  • Binary file processing
  • Multi-step pipelines

Processors should be pure functions - same input always produces same output. This ensures reproducible project generation.

Learning Path

Quick Example

Here's a minimal processor that uppercases all file content:

index.ts
import { StartProcessorWithLambda } from '@atomicloud/cyan-sdk';
StartProcessorWithLambda(async (input, fileHelper) => {
const files = fileHelper.resolveAll();
files.forEach(file => {
file.content = file.content.toUpperCase();
file.writeFile();
});
return { directory: input.writeDir };
});
main.py
from cyanprintsdk.processor import start_processor_with_fn
from cyanprintsdk.protocol import ProcessorInput, ProcessorOutput
async def processor(input: ProcessorInput, file_helper) -> ProcessorOutput:
files = file_helper.resolve_all()
for file in files:
file.content = file.content.upper()
file.write_file()
return ProcessorOutput(directory=input.write_dir)
processor_main = start_processor_with_fn(processor)
Processor.cs
using CyanPrintSDK;
public static class Processor
{
[ProcessorMain]
public static async Task<ProcessorOutput> Run(ProcessorInput input, CyanFileHelper fileHelper)
{
var files = fileHelper.ResolveAll();
foreach (var file in files)
{
file.Content = file.Content.ToUpper();
file.WriteFile();
}
return new ProcessorOutput { Directory = input.WriteDir };
}
}

Next Steps