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
-5
View File
@@ -23,11 +23,6 @@ var (
_ = strconv.FormatUint
)
const (
WorkflowResourceType = "corteza::automation:workflow"
ComponentResourceType = "corteza::automation"
)
// RbacResource returns string representation of RBAC resource for Workflow by calling WorkflowRbacResource fn
//
// RBAC resource is in the corteza::automation:workflow/... format
+14
View File
@@ -0,0 +1,14 @@
package types
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
const (
WorkflowResourceType = "corteza::automation:workflow"
SessionResourceType = "corteza::automation:session"
TriggerResourceType = "corteza::automation:trigger"
ComponentResourceType = "corteza::automation"
)
@@ -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
},
]
}
},
]
-10
View File
@@ -23,16 +23,6 @@ var (
_ = strconv.FormatUint
)
const (
ChartResourceType = "corteza::compose:chart"
ModuleResourceType = "corteza::compose:module"
ModuleFieldResourceType = "corteza::compose:module-field"
NamespaceResourceType = "corteza::compose:namespace"
PageResourceType = "corteza::compose:page"
RecordResourceType = "corteza::compose:record"
ComponentResourceType = "corteza::compose"
)
// RbacResource returns string representation of RBAC resource for Chart by calling ChartRbacResource fn
//
// RBAC resource is in the corteza::compose:chart/... format
+18
View File
@@ -0,0 +1,18 @@
package types
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
const (
AttachmentResourceType = "corteza::compose:attachment"
ChartResourceType = "corteza::compose:chart"
ModuleResourceType = "corteza::compose:module"
ModuleFieldResourceType = "corteza::compose:module-field"
NamespaceResourceType = "corteza::compose:namespace"
PageResourceType = "corteza::compose:page"
RecordResourceType = "corteza::compose:record"
ComponentResourceType = "corteza::compose"
)
-7
View File
@@ -23,13 +23,6 @@ var (
_ = strconv.FormatUint
)
const (
NodeResourceType = "corteza::federation:node"
ExposedModuleResourceType = "corteza::federation:exposed-module"
SharedModuleResourceType = "corteza::federation:shared-module"
ComponentResourceType = "corteza::federation"
)
// RbacResource returns string representation of RBAC resource for Node by calling NodeRbacResource fn
//
// RBAC resource is in the corteza::federation:node/... format
+16
View File
@@ -0,0 +1,16 @@
package types
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
const (
NodeResourceType = "corteza::federation:node"
NodeSyncResourceType = "corteza::federation:node-sync"
ExposedModuleResourceType = "corteza::federation:exposed-module"
SharedModuleResourceType = "corteza::federation:shared-module"
ModuleMappingResourceType = "corteza::federation:module-mapping"
ComponentResourceType = "corteza::federation"
)
-14
View File
@@ -23,20 +23,6 @@ var (
_ = strconv.FormatUint
)
const (
ApplicationResourceType = "corteza::system:application"
ApigwRouteResourceType = "corteza::system:apigw-route"
AuthClientResourceType = "corteza::system:auth-client"
DataPrivacyRequestResourceType = "corteza::system:data-privacy-request"
QueueResourceType = "corteza::system:queue"
ReportResourceType = "corteza::system:report"
RoleResourceType = "corteza::system:role"
TemplateResourceType = "corteza::system:template"
UserResourceType = "corteza::system:user"
DalConnectionResourceType = "corteza::system:dal-connection"
ComponentResourceType = "corteza::system"
)
// RbacResource returns string representation of RBAC resource for Application by calling ApplicationRbacResource fn
//
// RBAC resource is in the corteza::system:application/... format
+34
View File
@@ -0,0 +1,34 @@
package types
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
const (
AttachmentResourceType = "corteza::system:attachment"
ApplicationResourceType = "corteza::system:application"
ApigwRouteResourceType = "corteza::system:apigw-route"
ApigwFilterResourceType = "corteza::system:apigw-filter"
AuthClientResourceType = "corteza::system:auth-client"
AuthConfirmedClientResourceType = "corteza::system:auth-confirmed-client"
AuthSessionResourceType = "corteza::system:auth-session"
AuthOa2tokenResourceType = "corteza::system:auth-oa2token"
CredentialResourceType = "corteza::system:credential"
DataPrivacyRequestResourceType = "corteza::system:data-privacy-request"
DataPrivacyRequestCommentResourceType = "corteza::system:data-privacy-request-comment"
QueueResourceType = "corteza::system:queue"
QueueMessageResourceType = "corteza::system:queue_message"
ReminderResourceType = "corteza::system:reminder"
ReportResourceType = "corteza::system:report"
ResourceTranslationResourceType = "corteza::system:resource-translation"
RoleResourceType = "corteza::system:role"
RoleMemberResourceType = "corteza::system:role_member"
SettingValueResourceType = "corteza::system:settings"
TemplateResourceType = "corteza::system:template"
UserResourceType = "corteza::system:user"
DalConnectionResourceType = "corteza::system:dal-connection"
DalSensitivityLevelResourceType = "corteza::system:dal-sensitivity-level"
ComponentResourceType = "corteza::system"
)