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:
- codegen definitions in
codegen/ - templates in
codegen/asset/templates - schemas in
codegen/schema - template exec tool in
codegen/tool
Platform, component and resource definitions (.cue files) can be found in:
appautomationsystemcomposefederation
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
- evaluate codegen instructions (see platform.cue)
- output instructions as JSON
- pipe JSON into template exec tool
- 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