3
0

Reorganized and split (rbac) resource type codegen

This commit is contained in:
Denis Arh
2022-08-17 19:28:34 +02:00
parent ccfb4c09bb
commit 1eff906a44
12 changed files with 122 additions and 44 deletions
@@ -23,13 +23,6 @@ var (
_ = strconv.FormatUint
)
const (
{{- range .types }}
{{ .const }} = {{ printf "%q" .type }}
{{- end }}
)
{{- range .types }}
// RbacResource returns string representation of RBAC resource for {{ .goType }} by calling {{ .resFunc }} fn
@@ -0,0 +1,9 @@
package {{ .package }}
{{ template "gocode/header-gentext.tpl" }}
const (
{{- range .types }}
{{ .const }} = {{ printf "%q" .type }}
{{- end }}
)
+1 -1
View File
@@ -8,7 +8,7 @@ import (
[...schema.#codegen] &
[
for cmp in app.corteza.components {
template: "gocode/rbac/$component_types.go.tpl"
template: "gocode/rbac/$component_types_rbac.go.tpl"
output: "\(cmp.ident)/types/rbac.gen.go"
payload: {
package: "types"
+30
View File
@@ -0,0 +1,30 @@
package codegen
import (
"github.com/cortezaproject/corteza-server/app"
"github.com/cortezaproject/corteza-server/codegen/schema"
)
[...schema.#codegen] &
[
for cmp in app.corteza.components {
template: "gocode/types/$component_resources.go.tpl"
output: "\(cmp.ident)/types/resources.gen.go"
payload: {
package: "types"
cmpIdent: cmp.ident
// Operation/resource validators, grouped by resource
types: [
for res in cmp.resources {
const: "\(res.expIdent)ResourceType"
type: res.fqrn
},
{
const: "ComponentResourceType"
type: cmp.fqrn
},
]
}
},
]