3
0

Prepare codegen schema for Envoy templates

This commit is contained in:
Tomaž Jerman 2023-02-16 16:30:30 +01:00
parent b1d4531748
commit 7ed70a374f
2 changed files with 106 additions and 0 deletions

View File

@ -71,6 +71,11 @@ import (
// #ModelAttributeJsonTag
dal?: #ModelAttributeDal
envoy: {
$attrIdent: ident
} & #attributeEnvoy
// specifies all of the identifiers this attribute may define when using getters/setters
identAlias: [...string] | *[ident, expIdent]
@ -79,6 +84,32 @@ import (
omitGetter: bool | *false
}
#attributeEnvoy: {
$attrIdent: string
// controls if this attribute can be used as an identifier
identifier: bool | *false
// YAML decode/encode configs
yaml: {
identKeyLabel: string | *strings.ToLower($attrIdent)
identKeyAlias: [...string] | *[]
// identKeys defines what identifiers this attribute supports when
// decoding yaml documents
identKeys: ([identKeyLabel]+identKeyAlias)
customDecoder: bool | *false
customEncoder: bool | *false
}
// store decode/encode configs
store: {
// defines a custom field identifier when constructing
// resource filters and assigning reference constraints
filterRefField: string | *""
}
}
#ModelAttributeDal: {
type: #ModelAttributeDalType | *"Text"
@ -171,6 +202,10 @@ IdField: {
// @todo someday we'll replace this with the "ID" type
goType: "uint64"
dal: { type: "ID" }
envoy: #attributeEnvoy & {
identifier: true
}
}
HandleField: {
// Expecting ID field to always have name handle
@ -180,6 +215,10 @@ HandleField: {
goType: "string"
dal: { type: "Text", length: 64 }
envoy: #attributeEnvoy & {
identifier: true
}
}
AttributeUserRef: {

View File

@ -89,6 +89,14 @@ import (
}
}
envoy?: #resourceEnvoy & {
// @todo temporary; easier development on less resources
use: bool | *false
omit: bool | *false
$resourceIdent: ident
}
store?: {
// how is this resource represented (prefixed/suffixed functions) in the store
"ident": #ident | *ident
@ -135,3 +143,62 @@ import (
import: string
}
}
#resourceEnvoy: {
$resourceIdent: string
// @todo remove use, temporary for now
use: bool
omit: bool
// Scoped resources prioritize matching with resources in the same scope.
// This is useful when we want to import multiple namespaces at the same time.
scoped: bool | *false
// YAML decode/encode configs
yaml: {
// supportMappedInput controls whether the resource can be presented in
// a mapping node where the key of the map is an identifier.
//
// An example:
//
// modules:
// module1:
// name: module 1 name
//
// Where a resource with no mapping would look like:
//
// modules:
// - handle: module1
// name: module 1 name
supportMappedInput: bool | *true
// mappedField controls what identifier the map key represents
// @todo this can probably be inferred so consider removing it.
mappedField: string
identKeyLabel: string | *strings.ToLower($resourceIdent)
identKeyAlias: [...string] | *[]
// identKeys defines all of the identifiers that can be used when
// referencing this resource
identKeys: [...string] | *([identKeyLabel]+identKeyAlias)
}
// store decode/encode configs
store: {
// enable or disable additional custom processing for determining
// resource references
extendedRefDecoder: bool | *false
handleField: string | *"Handle"
customFilterBuilder: bool | *false
// extendedFilterBuilder is called after the built-in which you can use
// to append additional constraints to.
//
// Does nothing if customFilterBuilder is set to true
extendedFilterBuilder: bool | *false
// extendedDecoder is called after the built-in which you can use
// to append additional nodes into.
extendedDecoder: bool | *false
}
}