Add cue tooling & codegen to makefile
This commit is contained in:
3
.github/workflows/snapshot.yml
vendored
3
.github/workflows/snapshot.yml
vendored
@@ -27,7 +27,8 @@ jobs:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: ${{ runner.os }}-go-
|
||||
- run: make test.all
|
||||
- run: make test.codegen
|
||||
# - run: make test.all test.codegen
|
||||
|
||||
snapshot-docker:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
23
Makefile
23
Makefile
@@ -132,14 +132,29 @@ watch.test.%: $(FSWATCH)
|
||||
|
||||
watch.test: watch.test.unit
|
||||
|
||||
# codegen: $(PROTOGEN)
|
||||
codegen: $(CODEGEN)
|
||||
# See codegen/README.md for details
|
||||
codegen: $(CUE) $(JSONTPLEXEC)
|
||||
$(CUE) eval codegen/*.cue --out json -e platform | $(JSONTPLEXEC) -v
|
||||
|
||||
test.codegen: $(CUE) $(JSONTPLEXEC)
|
||||
$(CUE) eval codegen/*.cue --out json -e platform
|
||||
|
||||
cue.fmt: $(CUE)
|
||||
$(CUE) fmt -v codegen/*.cue
|
||||
$(CUE) fmt -v codegen/schema/*.cue
|
||||
$(CUE) fmt -v app/*.cue
|
||||
$(CUE) fmt system/*.cue
|
||||
$(CUE) fmt compose/*.cue
|
||||
# $(CUE) fmt automation/*.cue
|
||||
# $(CUE) fmt federation/*.cue
|
||||
|
||||
codegen-legacy: $(CODEGEN)
|
||||
@ $(CODEGEN) -v
|
||||
|
||||
watch.codegen: $(CODEGEN)
|
||||
watch.codegen-legacy: $(CODEGEN)
|
||||
@ $(CODEGEN) -w -v
|
||||
|
||||
clean.codegen:
|
||||
clean.codegen-legacy:
|
||||
rm -f $(CODEGEN)
|
||||
|
||||
provision:
|
||||
|
||||
@@ -19,7 +19,9 @@ PROTOGEN_GRPC = $(GOPATH)/bin/protoc-gen-go-grpc
|
||||
GIN = $(GOPATH)/bin/gin
|
||||
STATIK = $(GOPATH)/bin/statik
|
||||
MODOUTDATED = $(GOPATH)/bin/go-mod-outdated
|
||||
CUE = $(GOPATH)/bin/cue
|
||||
CODEGEN = build/codegen
|
||||
JSONTPLEXEC = build/json-tpl-exec
|
||||
|
||||
PROTOC = /usr/local/bin/protoc
|
||||
FSWATCH = /usr/local/bin/fswatch
|
||||
@@ -60,6 +62,13 @@ $(MODOUTDATED):
|
||||
$(CODEGEN):
|
||||
$(GO) build -o $@ cmd/codegen/main.go
|
||||
|
||||
$(CUE):
|
||||
$(GOINSTALL) cuelang.org/go/cmd/cue@latest
|
||||
|
||||
$(JSONTPLEXEC):
|
||||
$(GO) build -o $@ ./codegen/tool
|
||||
|
||||
clean-tools:
|
||||
rm -f $(BINS)
|
||||
|
||||
#
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
"github.com/cortezaproject/corteza-server/system"
|
||||
"github.com/cortezaproject/corteza-server/compose"
|
||||
)
|
||||
|
||||
81
codegen/README.md
Normal file
81
codegen/README.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# Corteza codegen tools and definitions
|
||||
|
||||
## History
|
||||
|
||||
See [old codegen](../pkh/codegen/README.md).
|
||||
|
||||
## 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.
|
||||
|
||||
## Intro
|
||||
|
||||
Codegen tools are based on [cuelang](https://cuelang.org/docs/tutorials/) and golang templates.
|
||||
|
||||
**What you can find here:**
|
||||
- [codegen definitions in `codegen/`](./)
|
||||
- [templates in `codegen/asset/templates`](./asset/templates)
|
||||
- [schemas in `codegen/schema`](./schema)
|
||||
- [template exec tool in `codegen/tool`](./tool)
|
||||
|
||||
Platform, component and resource definitions (.cue files) can be found in:
|
||||
- `app`
|
||||
- `automation` @todo
|
||||
- `system`
|
||||
- `compose`
|
||||
- `federation` @todo
|
||||
|
||||
## 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](../Makefile)
|
||||
|
||||
1. evaluate codegen instructions (see [platform.cue](./platform.cue))
|
||||
2. output instructions as JSON
|
||||
3. pipe JSON into [template exec tool](./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
|
||||
|
||||
- @todo options
|
||||
|
||||
- @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
|
||||
|
||||
@@ -95,8 +95,8 @@ envoyRBAC:
|
||||
|
||||
resources: [
|
||||
for cmp in app.corteza.components for res in cmp.resources if res.locale != _|_ {
|
||||
importAlias: "\(cmp.ident)Types"
|
||||
typeConst: "\(importAlias).\(res.expIdent)ResourceTranslationType"
|
||||
importAlias: "\(cmp.ident)Types"
|
||||
typeConst: "\(importAlias).\(res.expIdent)ResourceTranslationType"
|
||||
resTrRefFunc: "\(cmp.expIdent)\(res.expIdent)ResourceTranslationReferences"
|
||||
references: [
|
||||
for p in res.parents {p},
|
||||
@@ -110,25 +110,25 @@ envoyRBAC:
|
||||
[
|
||||
// wrapped with additional for loop to trim out templates with empty types list
|
||||
for tpl in [
|
||||
for cmp in app.corteza.components {
|
||||
template: "gocode/envoy/resource_translation_references_$component.go.tpl"
|
||||
output: "pkg/envoy/resource/resource_translation_references_\(cmp.ident).gen.go"
|
||||
payload: {
|
||||
package: "resource"
|
||||
imports: [
|
||||
"\"github.com/cortezaproject/corteza-server/\(cmp.ident)/types\"",
|
||||
]
|
||||
for cmp in app.corteza.components {
|
||||
template: "gocode/envoy/resource_translation_references_$component.go.tpl"
|
||||
output: "pkg/envoy/resource/resource_translation_references_\(cmp.ident).gen.go"
|
||||
payload: {
|
||||
package: "resource"
|
||||
imports: [
|
||||
"\"github.com/cortezaproject/corteza-server/\(cmp.ident)/types\"",
|
||||
]
|
||||
|
||||
resources: [
|
||||
for res in cmp.resources if res.locale != _|_ {
|
||||
resTrRefFunc: "\(cmp.expIdent)\(res.expIdent)ResourceTranslationReferences"
|
||||
expIdent: res.expIdent
|
||||
references: [
|
||||
for p in res.parents {p},
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
] if len(tpl.payload.resources) > 0 {tpl}]+
|
||||
resources: [
|
||||
for res in cmp.resources if res.locale != _|_ {
|
||||
resTrRefFunc: "\(cmp.expIdent)\(res.expIdent)ResourceTranslationReferences"
|
||||
expIdent: res.expIdent
|
||||
references: [
|
||||
for p in res.parents {p},
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
] if len(tpl.payload.resources) > 0 {tpl}]+
|
||||
[]
|
||||
|
||||
56
codegen/schema/locale.cue
Normal file
56
codegen/schema/locale.cue
Normal file
@@ -0,0 +1,56 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"list"
|
||||
)
|
||||
|
||||
#locale: {
|
||||
resourceExpIdent: #expIdent
|
||||
|
||||
// @todo we need a better name here!
|
||||
skipSvc: bool | *false
|
||||
|
||||
extended: bool | *false
|
||||
|
||||
resource: {
|
||||
// @todo merge with RBAC res-ref and move 2 levels lower.
|
||||
references: [ ...string] | *["ID"]
|
||||
type: string
|
||||
const: string | *("\(resourceExpIdent)ResourceTranslationType")
|
||||
}
|
||||
|
||||
keys: {
|
||||
[key=_]: #localeKey & {
|
||||
name: key
|
||||
_resourceExpIdent: resourceExpIdent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#localeKey: {
|
||||
name: #handle
|
||||
_resourceExpIdent: #expIdent
|
||||
|
||||
path: [...(#ident | {part: #ident, var: bool | *false})] | *([name])
|
||||
|
||||
expandedPath: [ for p in path {
|
||||
if (p & {"p": #ident}) != _|_ {p, var: p.var}
|
||||
if (p & string) != _|_ {"part": p, var: false}
|
||||
}]
|
||||
|
||||
_suffix: strings.Join([ for p in expandedPath {strings.ToTitle(p.part)}], "")
|
||||
|
||||
struct: string | *("LocaleKey" + _resourceExpIdent + _suffix)
|
||||
|
||||
// As soon as we use vars in the path,
|
||||
// custom handler must be present
|
||||
_hasVars: list.Contains([ for p in path {p.var | false}], true)
|
||||
customHandler: bool | *_hasVars
|
||||
|
||||
if customHandler {
|
||||
decodeFunc: string | *("decodeTranslations" + _suffix)
|
||||
encodeFunc: string | *("encodeTranslations" + _suffix)
|
||||
serviceFunc: string | *("handle" + _resourceExpIdent + _suffix)
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
operations: {
|
||||
[key=_]: #rbacOperation & {
|
||||
handle: key
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
|
||||
operations: {
|
||||
[key=_]: #rbacOperation & {
|
||||
handle: key
|
||||
handle: key
|
||||
_resourceExpIdent: resourceExpIdent
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ package schema
|
||||
component: #baseHandle | *"component"
|
||||
platform: #baseHandle | *"corteza"
|
||||
|
||||
|
||||
// Fully qualified resource name
|
||||
fqrn: string | *(platform + "::" + component + ":" + handle)
|
||||
|
||||
@@ -16,11 +15,11 @@ package schema
|
||||
|
||||
// All parent resources
|
||||
parents: [... #_base & {
|
||||
// copy field values from #_base
|
||||
handle: handle, ident: ident, expIdent: expIdent
|
||||
// copy field values from #_base
|
||||
handle: handle, ident: ident, expIdent: expIdent
|
||||
|
||||
refField: #expIdent | *(expIdent + "ID")
|
||||
param: #ident | *(ident + "ID")
|
||||
param: #ident | *(ident + "ID")
|
||||
}]
|
||||
|
||||
// All known RBAC operations for this resource
|
||||
@@ -29,7 +28,7 @@ package schema
|
||||
}
|
||||
|
||||
locale?: #locale & {
|
||||
resourceExpIdent: expIdent
|
||||
resourceExpIdent: expIdent
|
||||
resource: {
|
||||
// @todo can we merge this with RBAC type (FQRN?)
|
||||
type: component + ":" + handle
|
||||
@@ -47,23 +46,23 @@ package schema
|
||||
}
|
||||
|
||||
//#fields: {
|
||||
// // Each field can be
|
||||
// [key=_]: #fields | *({name: key} & #field)
|
||||
// // Each field can be
|
||||
// [key=_]: #fields | *({name: key} & #field)
|
||||
//}
|
||||
//
|
||||
//#field: {
|
||||
// name: #expIdent
|
||||
// unique: bool | *false
|
||||
// name: #expIdent
|
||||
// unique: bool | *false
|
||||
//
|
||||
// // Golang type (built-in or other)
|
||||
// type: string | *"string"
|
||||
// // Golang type (built-in or other)
|
||||
// type: string | *"string"
|
||||
//
|
||||
// // System fields,
|
||||
// system: bool | *false
|
||||
// // System fields,
|
||||
// system: bool | *false
|
||||
//
|
||||
// if name =~ "At$" {
|
||||
// type: string | *"*time.Time"
|
||||
// }
|
||||
// if name =~ "At$" {
|
||||
// type: string | *"*time.Time"
|
||||
// }
|
||||
//}
|
||||
|
||||
//#Operations: {
|
||||
@@ -77,23 +76,23 @@ package schema
|
||||
//}
|
||||
|
||||
//idField: {
|
||||
// // Expecting ID field to allways have name ID
|
||||
// name: "ID"
|
||||
// unique: true
|
||||
// // Expecting ID field to allways have name ID
|
||||
// name: "ID"
|
||||
// unique: true
|
||||
//
|
||||
// // Service fields,
|
||||
// // @todo We might want to have a better name for this
|
||||
// // service: true
|
||||
// // Service fields,
|
||||
// // @todo We might want to have a better name for this
|
||||
// // service: true
|
||||
//
|
||||
// // @todo someday we'll replace this with the "ID" type
|
||||
// type: "uint64"
|
||||
// // @todo someday we'll replace this with the "ID" type
|
||||
// type: "uint64"
|
||||
//}
|
||||
//
|
||||
//handleField: {
|
||||
// // Expecting ID field to allways have name ID
|
||||
// name: "handle"
|
||||
// unique: true
|
||||
// // Expecting ID field to allways have name ID
|
||||
// name: "handle"
|
||||
// unique: true
|
||||
//
|
||||
// // @todo someday we'll replace this with the "ID" type
|
||||
// type: "string" & #handle
|
||||
// // @todo someday we'll replace this with the "ID" type
|
||||
// type: "string" & #handle
|
||||
//}
|
||||
@@ -13,21 +13,20 @@ import (
|
||||
// More liberal then identifier, allows underscores and dots
|
||||
#handle: =~"^[A-Za-z][a-zA-Z0-9_\\-\\.]*[a-zA-Z0-9]+$"
|
||||
|
||||
|
||||
// More liberal then identifier, allows underscores and dots
|
||||
#baseHandle: =~"^[a-z][a-z0-9-]*[a-z0-9]+$"
|
||||
|
||||
#_base: {
|
||||
// lowercase dash-separated words
|
||||
// used to build ident and exported identifiers
|
||||
handle: #baseHandle | *"base"
|
||||
_words: strings.Replace(strings.Replace(strings.Replace(handle, "-", " ", -1), "_", " ", -1), ".", " ", -1)
|
||||
handle: #baseHandle | *"base"
|
||||
_words: strings.Replace(strings.Replace(strings.Replace(handle, "-", " ", -1), "_", " ", -1), ".", " ", -1)
|
||||
|
||||
// lowercased (unexported, golang) identifier
|
||||
ident: #ident | *strings.ToCamel(strings.Replace(strings.ToTitle(_words), " ", "", -1))
|
||||
ident: #ident | *strings.ToCamel(strings.Replace(strings.ToTitle(_words), " ", "", -1))
|
||||
|
||||
// upercased (exported, golang) identifier
|
||||
expIdent: #expIdent | *strings.Replace(strings.ToTitle(_words), " ", "", -1)
|
||||
expIdent: #expIdent | *strings.Replace(strings.ToTitle(_words), " ", "", -1)
|
||||
|
||||
...
|
||||
}
|
||||
@@ -24,6 +24,10 @@ func LoadTemplates(rTpl *template.Template, rootDir string) (*template.Template,
|
||||
pfx := len(cleanRoot) + 1
|
||||
|
||||
return rTpl, filepath.Walk(cleanRoot, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if info.IsDir() || !strings.HasSuffix(path, ".tpl") || err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package compose
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
chart: schema.#resource & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package compose
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
component: schema.#component & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package compose
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
moduleField: schema.#resource & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package compose
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
module: schema.#resource & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package compose
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
namespace: schema.#resource & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package compose
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
page: schema.#resource & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package compose
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
record: schema.#resource & {
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
See `pkg/codegen-v3/README.md`
|
||||
Obsolete and pending removal.
|
||||
|
||||
All automation.* & federation.* yamls need to be converted
|
||||
to cue and moved to automation/
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
rbac:
|
||||
resource:
|
||||
references: [ namespace, ID ]
|
||||
|
||||
operations:
|
||||
read:
|
||||
description: Read chart
|
||||
update:
|
||||
description: Update chart
|
||||
delete:
|
||||
description: Delete chart
|
||||
|
||||
# locale:
|
||||
# resource:
|
||||
# references: [ namespace, ID ]
|
||||
# keys:
|
||||
# - name
|
||||
@@ -1,29 +0,0 @@
|
||||
rbac:
|
||||
resource:
|
||||
references: [ namespace, module, ID ]
|
||||
|
||||
operations:
|
||||
record.value.read:
|
||||
canFnName: CanReadRecordValue
|
||||
description: Read field value on records
|
||||
record.value.update:
|
||||
canFnName: CanUpdateRecordValue
|
||||
description: Update field value on records
|
||||
|
||||
locale:
|
||||
resource:
|
||||
references: [ namespace, module, ID ]
|
||||
|
||||
skipSvc: true
|
||||
keys:
|
||||
- label
|
||||
- { name: descriptionView, path: meta.description.view, custom: true, customHandler: descriptionView }
|
||||
- { name: descriptionEdit, path: meta.description.edit, custom: true, customHandler: descriptionEdit }
|
||||
- { name: hintView, path: meta.hint.view, custom: true, customHandler: hintView }
|
||||
- { name: hintEdit, path: meta.hint.edit, custom: true, customHandler: hintEdit }
|
||||
- { name: validatorError, path: "expression.validator.{{validatorID}}.error", custom: true, customHandler: validatorError }
|
||||
- { name: optionsOptionTexts,
|
||||
path: "meta.options.{{value}}.text",
|
||||
custom: true,
|
||||
customHandler: optionsOptionTexts
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
rbac:
|
||||
resource:
|
||||
references: [ namespace, ID ]
|
||||
|
||||
operations:
|
||||
read:
|
||||
description: Read module
|
||||
update:
|
||||
description: Update module
|
||||
delete:
|
||||
description: Delete module
|
||||
|
||||
record.create:
|
||||
description: Create record
|
||||
records.search:
|
||||
description: List, search or filter records
|
||||
|
||||
locale:
|
||||
resource:
|
||||
references: [ namespace, ID ]
|
||||
|
||||
extended: true
|
||||
keys:
|
||||
- name
|
||||
@@ -1,31 +0,0 @@
|
||||
rbac:
|
||||
operations:
|
||||
read:
|
||||
description: Read namespace
|
||||
update:
|
||||
description: Update namespace
|
||||
delete:
|
||||
description: Delete namespace
|
||||
manage:
|
||||
description: Access to namespace admin panel
|
||||
|
||||
module.create:
|
||||
description: Create module on namespace
|
||||
modules.search:
|
||||
description: List, search or filter module on namespace
|
||||
|
||||
chart.create:
|
||||
description: Create chart on namespace
|
||||
charts.search:
|
||||
description: List, search or filter chart on namespace
|
||||
|
||||
page.create:
|
||||
description: Create page on namespace
|
||||
pages.search:
|
||||
description: List, search or filter pages on namespace
|
||||
|
||||
locale:
|
||||
keys:
|
||||
- name
|
||||
- { path: subtitle, field: "Meta.Subtitle" }
|
||||
- { path: description, field: "Meta.Description" }
|
||||
@@ -1,23 +0,0 @@
|
||||
rbac:
|
||||
resource:
|
||||
references: [ namespace, ID ]
|
||||
|
||||
operations:
|
||||
read:
|
||||
description: Read page
|
||||
update:
|
||||
description: Update page
|
||||
delete:
|
||||
description: Delete page
|
||||
|
||||
locale:
|
||||
resource:
|
||||
references: [ namespace, ID ]
|
||||
|
||||
extended: true
|
||||
keys:
|
||||
- title
|
||||
- description
|
||||
- { name: blockTitle, path: "pageBlock.{{blockID}}.title", custom: true }
|
||||
- { name: blockDescription, path: "pageBlock.{{blockID}}.description", custom: true }
|
||||
- { name: blockAutomationButtonlabel, path: "pageBlock.{{blockID}}.button.{{buttonID}}.label", custom: true }
|
||||
@@ -1,11 +0,0 @@
|
||||
rbac:
|
||||
resource:
|
||||
references: [ namespace, module, ID ]
|
||||
|
||||
operations:
|
||||
read:
|
||||
description: Read record
|
||||
update:
|
||||
description: Update record
|
||||
delete:
|
||||
description: Delete record
|
||||
@@ -1,19 +0,0 @@
|
||||
rbac:
|
||||
resource: { references: [] }
|
||||
|
||||
operations:
|
||||
grant:
|
||||
description: Manage Compose permissions
|
||||
|
||||
settings.read:
|
||||
description: Read settings
|
||||
settings.manage:
|
||||
description: Manage settings
|
||||
|
||||
namespace.create:
|
||||
description: Create namespace
|
||||
namespaces.search:
|
||||
description: List, search or filter namespaces
|
||||
|
||||
resource-translations.manage:
|
||||
description: List, search, create, or update resource translations
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "boolean",
|
||||
"enum": [ "false" ],
|
||||
"title": "Disable envoy support",
|
||||
"description": "Enabled by default"
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"resource": {
|
||||
"additionalProperties": false,
|
||||
"type": "object",
|
||||
"description": "RBAC resource definition",
|
||||
"properties": {
|
||||
"prefix": {
|
||||
"type": "string",
|
||||
"description": "Resource name",
|
||||
"pattern": "^[a-z]+:?[a-zA-Z]+(:[a-zA-Z]+)?$"
|
||||
},
|
||||
"references": {
|
||||
"type": "array",
|
||||
"title": "Reference components",
|
||||
"description": "When not explicitly defined it fallbacks to one item array with 'ID'",
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"field": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"attributes": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"enum": [ "true" ],
|
||||
"title": "Custom implementation of resource attributes",
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"title": "List of resource attributes",
|
||||
"description": "Attributes are used for generating list of contextual roles"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"operations": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"patternProperties": {
|
||||
"^([a-z]+(-[a-z]+)*)(\\.[a-z]+)*$": {
|
||||
"anyOf": [
|
||||
{ "type": "boolean", "enum": [ "false" ] },
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"canFnName": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
26
def/def.json
26
def/def.json
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"$id": "https://schemas.cortezaproject.org/def.json",
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"imports": {
|
||||
"type": "array",
|
||||
"title": "List of go packages to be imported when generating files",
|
||||
"description": "Attributes are used for generating list of contextual roles"
|
||||
},
|
||||
|
||||
"component": {
|
||||
"type": "string",
|
||||
"title": "Component of the definition",
|
||||
"description": "By default, component is taken from the filename of the definition: from start of the filename to the first dot"
|
||||
},
|
||||
"resource": {
|
||||
"type": "string",
|
||||
"title": "Resource of the definition",
|
||||
"description": "By default, resource is taken from the filename of the definition: from the first dot to the end of the filename without extension"
|
||||
},
|
||||
"rbac": { "$ref": "def-rbac.json" },
|
||||
"envoy": { "$ref": "def-envoy.json" }
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"list"
|
||||
)
|
||||
|
||||
|
||||
#locale: {
|
||||
resourceExpIdent: #expIdent
|
||||
|
||||
// @todo we need a better name here!
|
||||
skipSvc: bool | *false
|
||||
|
||||
extended: bool | *false
|
||||
|
||||
resource: {
|
||||
// @todo merge with RBAC res-ref and move 2 levels lower.
|
||||
references: [ ...string] | *["ID"]
|
||||
type: string
|
||||
const: string | *("\(resourceExpIdent)ResourceTranslationType")
|
||||
}
|
||||
|
||||
keys: {
|
||||
[key=_]: #localeKey & {
|
||||
name: key
|
||||
_resourceExpIdent: resourceExpIdent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#localeKey: {
|
||||
name: #handle
|
||||
_resourceExpIdent: #expIdent
|
||||
|
||||
path: [...(#ident | { part: #ident, var: bool | *false })] | *([name])
|
||||
|
||||
expandedPath: [for p in path {
|
||||
if (p & { "p": #ident }) != _|_ { p, var: p.var }
|
||||
if (p & string) != _|_ { "part": p, var: false }
|
||||
}]
|
||||
|
||||
|
||||
_suffix: strings.Join([for p in expandedPath { strings.ToTitle(p.part) }], "")
|
||||
|
||||
struct: string | *("LocaleKey" + _resourceExpIdent + _suffix)
|
||||
|
||||
// As soon as we use vars in the path,
|
||||
// custom handler must be present
|
||||
_hasVars: list.Contains([for p in path { p.var | false }], true)
|
||||
customHandler: bool | *_hasVars
|
||||
|
||||
if customHandler {
|
||||
decodeFunc: string | *("decodeTranslations" + _suffix)
|
||||
encodeFunc: string | *("encodeTranslations" + _suffix)
|
||||
serviceFunc: string | *("handle" + _resourceExpIdent + _suffix)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
rbac:
|
||||
operations:
|
||||
read:
|
||||
description: Read API Gateway route
|
||||
update:
|
||||
description: Update API Gateway route
|
||||
delete:
|
||||
description: Delete API Gateway route
|
||||
@@ -1,8 +0,0 @@
|
||||
rbac:
|
||||
operations:
|
||||
read:
|
||||
description: Read application
|
||||
update:
|
||||
description: Update application
|
||||
delete:
|
||||
description: Delete application
|
||||
@@ -1,10 +0,0 @@
|
||||
rbac:
|
||||
operations:
|
||||
read:
|
||||
description: Read authorization client
|
||||
update:
|
||||
description: Update authorization client
|
||||
delete:
|
||||
description: Delete authorization client
|
||||
authorize:
|
||||
description: Authorize authorization client
|
||||
@@ -1,12 +0,0 @@
|
||||
rbac:
|
||||
operations:
|
||||
read:
|
||||
description: Read queue
|
||||
update:
|
||||
description: Update queue
|
||||
delete:
|
||||
description: Delete queue
|
||||
queue.read:
|
||||
description: Read from queue
|
||||
queue.write:
|
||||
description: Write to queue
|
||||
@@ -1,18 +0,0 @@
|
||||
rbac:
|
||||
operations:
|
||||
read:
|
||||
description: Read report
|
||||
update:
|
||||
description: Update report
|
||||
delete:
|
||||
description: Delete report
|
||||
run:
|
||||
description: Run report
|
||||
|
||||
# locale:
|
||||
# extended: true
|
||||
# keys:
|
||||
# - { path: name, field: "Meta.Name" }
|
||||
# - { path: description, field: "Meta.Description" }
|
||||
# - { name: block title, path: "block.{{blockID}}.title", custom: true }
|
||||
# - { name: block description, path: "block.{{blockID}}.description", custom: true }
|
||||
@@ -1,10 +0,0 @@
|
||||
rbac:
|
||||
operations:
|
||||
read:
|
||||
description: Read role
|
||||
update:
|
||||
description: Update role
|
||||
delete:
|
||||
description: Delete role
|
||||
members.manage:
|
||||
description: Manage members
|
||||
@@ -1,10 +0,0 @@
|
||||
rbac:
|
||||
operations:
|
||||
read:
|
||||
description: Read template
|
||||
update:
|
||||
description: Update template
|
||||
delete:
|
||||
description: Delete template
|
||||
render:
|
||||
description: Render template
|
||||
@@ -1,19 +0,0 @@
|
||||
rbac:
|
||||
operations:
|
||||
read:
|
||||
description: Read user
|
||||
update:
|
||||
description: Update user
|
||||
delete:
|
||||
description: Delete user
|
||||
suspend:
|
||||
description: Suspemd user
|
||||
unsuspend:
|
||||
description: Unsuspend user
|
||||
email.unmask:
|
||||
description: Unmask email
|
||||
name.unmask:
|
||||
description: Unmask name
|
||||
impersonate:
|
||||
description: Impersonate user
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
rbac:
|
||||
resource: { references: [] }
|
||||
|
||||
operations:
|
||||
grant:
|
||||
description: Manage system permissions
|
||||
|
||||
action-log.read:
|
||||
description: Access to action log
|
||||
|
||||
settings.read:
|
||||
description: Read system settings
|
||||
settings.manage:
|
||||
description: Manage system settings
|
||||
|
||||
auth-client.create:
|
||||
description: Create auth clients
|
||||
auth-clients.search:
|
||||
description: List, search or filter auth clients
|
||||
|
||||
role.create:
|
||||
description: Create roles
|
||||
roles.search:
|
||||
description: List, search or filter roles
|
||||
|
||||
user.create:
|
||||
description: Create users
|
||||
users.search:
|
||||
description: List, search or filter users
|
||||
|
||||
application.create:
|
||||
description: Create applications
|
||||
applications.search:
|
||||
description: List, search or filter auth clients
|
||||
application.flag.self:
|
||||
description: Manage private flags for applications
|
||||
application.flag.global:
|
||||
description: Manage global flags for applications
|
||||
|
||||
template.create:
|
||||
description: Create template
|
||||
templates.search:
|
||||
description: List, search or filter templates
|
||||
|
||||
report.create:
|
||||
description: Create report
|
||||
reports.search:
|
||||
description: List, search or filter reports
|
||||
|
||||
reminder.assign:
|
||||
description: Assign reminders
|
||||
|
||||
queue.create:
|
||||
description: Create messagebus queues
|
||||
queues.search:
|
||||
description: List, search or filter messagebus queues
|
||||
|
||||
apigw-route.create:
|
||||
description: Create API gateway route
|
||||
apigw-routes.search:
|
||||
description: List search or filter API gateway routes
|
||||
|
||||
resource-translations.manage:
|
||||
description: List, search, create, or update resource translations
|
||||
@@ -1,5 +1,7 @@
|
||||
# Code generation package
|
||||
|
||||
See [latest codegen version](../../codegen/README.md).
|
||||
|
||||
It consumes YAMLs from all known locations and provides them to
|
||||
templates
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
apigwRoute: schema.#resource & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
application: schema.#resource & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
authClient: schema.#resource & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
component: schema.#component & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
queue: schema.#resource & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
report: schema.#resource & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
role: schema.#resource & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
template: schema.#resource & {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/def/schema"
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
)
|
||||
|
||||
user: schema.#resource & {
|
||||
|
||||
Reference in New Issue
Block a user