3
0
Vivek Patel d26ca37fe0 Refactor RBAC rule cloning route for role
It moves role permission cloning under /system/roles from /system/permissions, since cloning action copies all rules, and it can not be limited per-component and also shifted all respective service methods to role service and removed Rbac rule cloning methods from access-control template.
2022-07-10 15:47:26 +05:30
..
2022-04-24 07:36:17 +02:00
2022-03-18 15:54:37 +01:00

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 (the root of the project)

make codegen

Inside /codegen you can run codegen with different options

# generate all
make 

# generate only server files (golang code, .env.example, ...)  
make server 

# generate only docs (asciidoc files)
make docs

# generate for only one specific codegen definition
make server.options.cue
make docs.options.cue

# or more of them at once
make server.options.cue docs.options.cue

How does it work?

High-level overview

See Makefile's codegen 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. endpoints (unrelated to specific component)

Troubleshooting

  1. Make sure you have the latest version of cue (0.4.2 or newer)