3
0

Corteza codegen tools and definitions

History

See old codegen.

Plans

Right now, Corteza is migrating its old YAML definitions to CUE. We are also simplifying all templates by moving as much data manipulation to Cue as possible.

Todo

  • options documentation (see assets/templates/docs/options.gen.adoc.tpl)

Intro

Codegen tools are based on cuelang and golang templates.

What you can find here:

Platform, component and resource definitions (.cue files) can be found in:

  • app
  • automation
  • system
  • compose
  • federation

Running code generator

When a definitions or templates are changed all outputs need to be regenerated

This can be done with the following command

make codegen

Please note that

How does it work?

High-level overview

See Makefile's codegen-cue task

  1. evaluate codegen instructions (see platform.cue)
  2. output instructions as JSON
  3. pipe JSON into template exec tool
  4. process instructions, load and execute templates and write to output files.

Definition structure

Codegen instructions

Collection of #codegen structs with template + payload + output instructions. Template exec tool iterates over collection and creates output from each one.

Platform

Main entry point that combines all components

  • options (see options.cue)
  • @todo REST endpoints (unrelated to specific component)

Component

Defines component, it's behaviour, RBAC operations and resources

  • @todo REST endpoints (unrelated to specific resources)

Resource

Defines resource, it's behaviour, types, RBAC operations, translatable keys

  • @todo events
  • @todo actions
  • @todo errors
  • @todo automation functions
  • @todo expression types
  • @todo REST endpoints