Files
kubevela/references/cuegen
Ai Ranthem a5606b7808
Some checks failed
CodeQL / Analyze (go) (push) Failing after 6m23s
Definition-Lint / definition-doc (push) Failing after 3m8s
E2E MultiCluster Test / detect-noop (push) Successful in 6s
E2E Test / detect-noop (push) Successful in 3s
Go / detect-noop (push) Successful in 2s
license / Check for unapproved licenses (push) Failing after 18s
Registry / publish-core-images (push) Failing after 1m4s
Unit-Test / detect-noop (push) Successful in 20s
Sync SDK / sync_sdk (push) Failing after 3m9s
Go / staticcheck (push) Successful in 6m17s
Go / check-diff (push) Failing after 19m4s
Go / check-core-image-build (push) Failing after 5m44s
Go / check-cli-image-build (push) Failing after 3m31s
Unit-Test / unit-tests (push) Failing after 13m54s
Go / lint (push) Failing after 1h53m27s
Scorecards supply-chain security / Scorecards analysis (push) Failing after 1m27s
E2E MultiCluster Test / e2e-multi-cluster-tests (v1.29) (push) Has been cancelled
E2E Test / e2e-tests (v1.29) (push) Has been cancelled
Go / check-windows (push) Has been cancelled
Chore: (deps): Update k8s to 1.29 (#6654)
* chore: update k8s to 1.29

Signed-off-by: phantomnat <w.nattadej@gmail.com>

* fix: unit test

Signed-off-by: phantomnat <w.nattadej@gmail.com>

* fix: lint

Signed-off-by: phantomnat <w.nattadej@gmail.com>

* fix: lint

Signed-off-by: phantomnat <w.nattadej@gmail.com>

* fix: e2e

Signed-off-by: phantomnat <w.nattadej@gmail.com>

* fix: lint and e2e test

Signed-off-by: phantomnat <w.nattadej@gmail.com>

* test(e2e): increase timeout

Signed-off-by: phantomnat <w.nattadej@gmail.com>

* fix e2e and scripts

Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>

* make reviewable

Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>

* rollback a unnecessary ut change

Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>

* update go.mod to import merged workflow

Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>

---------

Signed-off-by: phantomnat <w.nattadej@gmail.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Co-authored-by: phantomnat <w.nattadej@gmail.com>
2025-01-03 07:54:42 +08:00
..

CUE Generator

Auto generation of CUE schema and docs from Go struct

Type Conversion

  • All comments will be copied to CUE schema

Basic Types

Go Type CUE Type
int int
int8 int8
int16 int16
int32 int32
int64 int64
uint uint
uint8 uint8
uint16 uint16
uint32 uint32
uint64 uint64
float32 float32
float64 float64
string string
bool bool
nil null
byte uint8
uintptr uint64
[]byte bytes
interface{}/any _

Map Type

  • CUE only supports map[string]T type, which is converted to [string]: T in CUE schema
  • All map[string]any/map[string]interface{} are converted to {...} in CUE schema

Struct Type

  • Fields will be expanded recursively in CUE schema
  • All unexported fields will be ignored
  • Do not support recursive struct type, which will cause infinite loop

json Tag:

  • Fields with json:"FIELD_NAME" tag will be renamed to FIELD_NAME in CUE schema, otherwise the field name will be used
  • Fields with json:"-" tag will be ignored in generation
  • Anonymous fields with json:",inline" tag will be expanded inlined in CUE schema
  • Fields with json:",omitempty" tag will be marked as optional in CUE schema

cue Tag:

  • Format: cue:"key1:value1;key2:value2;boolValue1;boolValue2"
  • Fields with cue:"enum:VALUE1,VALUE2" tag will be set with enum values VALUE1 and VALUE2 in CUE schema
  • Fields with cue:"default:VALUE" tag will be set with default value VALUE in CUE schema, and VALUE must be one of go basic types, including int, float, string, bool
  • Separators ';', ':' and ',' can be escaped with '\', e.g. cue:"default:va\\;lue\\:;enum:e\\;num1,e\\:num2\\,enum3" will be parsed as Default: "va;lue:", Enum: []string{"e;num1", "e:num2,enum3"}}