diff --git a/automation/types/rbac.gen.go b/automation/types/rbac.gen.go index 9dabe3f2c..e1b61c3d7 100644 --- a/automation/types/rbac.gen.go +++ b/automation/types/rbac.gen.go @@ -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 diff --git a/automation/types/resources.gen.go b/automation/types/resources.gen.go new file mode 100644 index 000000000..86a419531 --- /dev/null +++ b/automation/types/resources.gen.go @@ -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" +) diff --git a/codegen/assets/templates/gocode/rbac/$component_types.go.tpl b/codegen/assets/templates/gocode/rbac/$component_types_rbac.go.tpl similarity index 95% rename from codegen/assets/templates/gocode/rbac/$component_types.go.tpl rename to codegen/assets/templates/gocode/rbac/$component_types_rbac.go.tpl index 760f0c04b..27cd73446 100644 --- a/codegen/assets/templates/gocode/rbac/$component_types.go.tpl +++ b/codegen/assets/templates/gocode/rbac/$component_types_rbac.go.tpl @@ -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 diff --git a/codegen/assets/templates/gocode/types/$component_resources.go.tpl b/codegen/assets/templates/gocode/types/$component_resources.go.tpl new file mode 100644 index 000000000..05cf2af14 --- /dev/null +++ b/codegen/assets/templates/gocode/types/$component_resources.go.tpl @@ -0,0 +1,9 @@ +package {{ .package }} + +{{ template "gocode/header-gentext.tpl" }} + +const ( +{{- range .types }} + {{ .const }} = {{ printf "%q" .type }} +{{- end }} +) diff --git a/codegen/server.rbac_types.cue b/codegen/server.rbac_types.cue index d50861003..34da2951e 100644 --- a/codegen/server.rbac_types.cue +++ b/codegen/server.rbac_types.cue @@ -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" diff --git a/codegen/server.types.cue b/codegen/server.types.cue new file mode 100644 index 000000000..003eac024 --- /dev/null +++ b/codegen/server.types.cue @@ -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 + }, + ] + } + }, +] diff --git a/compose/types/rbac.gen.go b/compose/types/rbac.gen.go index 4198023a2..b37752fac 100644 --- a/compose/types/rbac.gen.go +++ b/compose/types/rbac.gen.go @@ -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 diff --git a/compose/types/resources.gen.go b/compose/types/resources.gen.go new file mode 100644 index 000000000..aab14d685 --- /dev/null +++ b/compose/types/resources.gen.go @@ -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" +) diff --git a/federation/types/rbac.gen.go b/federation/types/rbac.gen.go index 9e677c77c..b29f0f96e 100644 --- a/federation/types/rbac.gen.go +++ b/federation/types/rbac.gen.go @@ -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 diff --git a/federation/types/resources.gen.go b/federation/types/resources.gen.go new file mode 100644 index 000000000..535b98edd --- /dev/null +++ b/federation/types/resources.gen.go @@ -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" +) diff --git a/system/types/rbac.gen.go b/system/types/rbac.gen.go index 3085870b8..fdb6dc398 100644 --- a/system/types/rbac.gen.go +++ b/system/types/rbac.gen.go @@ -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 diff --git a/system/types/resources.gen.go b/system/types/resources.gen.go new file mode 100644 index 000000000..2ec37fcef --- /dev/null +++ b/system/types/resources.gen.go @@ -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" +)