From ac35d569a30f8f57f5e1949613065584cf140625 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Sat, 23 Apr 2022 17:13:34 +0200 Subject: [PATCH] Regenerated code after resource def. fix --- .../resource/rbac_references_system.gen.go | 39 ++- pkg/envoy/resource/rbac_rules_parse.gen.go | 27 +- store/adapters/rdbms/filters.gen.go | 5 +- store/adapters/rdbms/queries.gen.go | 156 +++++----- store/adapters/rdbms/rdbms.gen.go | 120 +++++--- store/adapters/rdbms/tx.go | 4 +- system/service/access_control.gen.go | 276 +++++++++++++----- system/types/rbac.gen.go | 109 ++++--- 8 files changed, 471 insertions(+), 265 deletions(-) diff --git a/pkg/envoy/resource/rbac_references_system.gen.go b/pkg/envoy/resource/rbac_references_system.gen.go index 4fb241d91..48b9083ae 100644 --- a/pkg/envoy/resource/rbac_references_system.gen.go +++ b/pkg/envoy/resource/rbac_references_system.gen.go @@ -10,19 +10,6 @@ import ( "github.com/cortezaproject/corteza-server/system/types" ) -// SystemApigwRouteRbacReferences generates RBAC references -// -// Resources with "envoy: false" are skipped -// -// This function is auto-generated -func SystemApigwRouteRbacReferences(apigwRoute string) (res *Ref, pp []*Ref, err error) { - if apigwRoute != "*" { - res = &Ref{ResourceType: types.ApigwRouteResourceType, Identifiers: MakeIdentifiers(apigwRoute)} - } - - return -} - // SystemApplicationRbacReferences generates RBAC references // // Resources with "envoy: false" are skipped @@ -36,6 +23,19 @@ func SystemApplicationRbacReferences(application string) (res *Ref, pp []*Ref, e return } +// SystemApigwRouteRbacReferences generates RBAC references +// +// Resources with "envoy: false" are skipped +// +// This function is auto-generated +func SystemApigwRouteRbacReferences(apigwRoute string) (res *Ref, pp []*Ref, err error) { + if apigwRoute != "*" { + res = &Ref{ResourceType: types.ApigwRouteResourceType, Identifiers: MakeIdentifiers(apigwRoute)} + } + + return +} + // SystemAuthClientRbacReferences generates RBAC references // // Resources with "envoy: false" are skipped @@ -62,6 +62,19 @@ func SystemQueueRbacReferences(queue string) (res *Ref, pp []*Ref, err error) { return } +// SystemQueueMessageRbacReferences generates RBAC references +// +// Resources with "envoy: false" are skipped +// +// This function is auto-generated +func SystemQueueMessageRbacReferences(queueMessage string) (res *Ref, pp []*Ref, err error) { + if queueMessage != "*" { + res = &Ref{ResourceType: types.QueueMessageResourceType, Identifiers: MakeIdentifiers(queueMessage)} + } + + return +} + // SystemReportRbacReferences generates RBAC references // // Resources with "envoy: false" are skipped diff --git a/pkg/envoy/resource/rbac_rules_parse.gen.go b/pkg/envoy/resource/rbac_rules_parse.gen.go index 58d30aae9..18b2fd674 100644 --- a/pkg/envoy/resource/rbac_rules_parse.gen.go +++ b/pkg/envoy/resource/rbac_rules_parse.gen.go @@ -47,15 +47,6 @@ func ParseRule(res string) (string, *Ref, []*Ref, error) { // make the resource provide the slice of parent resources we should nest under switch resourceType { - case systemTypes.ApigwRouteResourceType: - if len(path) != 1 { - return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path)) - } - ref, pp, err := SystemApigwRouteRbacReferences( - path[0], - ) - return resourceType, ref, pp, err - case systemTypes.ApplicationResourceType: if len(path) != 1 { return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path)) @@ -65,6 +56,15 @@ func ParseRule(res string) (string, *Ref, []*Ref, error) { ) return resourceType, ref, pp, err + case systemTypes.ApigwRouteResourceType: + if len(path) != 1 { + return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path)) + } + ref, pp, err := SystemApigwRouteRbacReferences( + path[0], + ) + return resourceType, ref, pp, err + case systemTypes.AuthClientResourceType: if len(path) != 1 { return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path)) @@ -83,6 +83,15 @@ func ParseRule(res string) (string, *Ref, []*Ref, error) { ) return resourceType, ref, pp, err + case systemTypes.QueueMessageResourceType: + if len(path) != 1 { + return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path)) + } + ref, pp, err := SystemQueueMessageRbacReferences( + path[0], + ) + return resourceType, ref, pp, err + case systemTypes.ReportResourceType: if len(path) != 1 { return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path)) diff --git a/store/adapters/rdbms/filters.gen.go b/store/adapters/rdbms/filters.gen.go index 1498508f1..08a40e1d5 100644 --- a/store/adapters/rdbms/filters.gen.go +++ b/store/adapters/rdbms/filters.gen.go @@ -7,8 +7,6 @@ package rdbms // import ( - "strings" - automationType "github.com/cortezaproject/corteza-server/automation/types" composeType "github.com/cortezaproject/corteza-server/compose/types" federationType "github.com/cortezaproject/corteza-server/federation/types" @@ -19,6 +17,7 @@ import ( rbacType "github.com/cortezaproject/corteza-server/pkg/rbac" systemType "github.com/cortezaproject/corteza-server/system/types" "github.com/doug-martin/goqu/v9" + "strings" ) type ( @@ -825,7 +824,7 @@ func FederationSharedModuleFilter(f federationType.SharedModuleFilter) (ee []goq } if f.NodeID > 0 { - ee = append(ee, goqu.C("ref_node").Eq(f.NodeID)) + ee = append(ee, goqu.C("rel_node").Eq(f.NodeID)) } if val := strings.TrimSpace(f.Name); len(val) > 0 { diff --git a/store/adapters/rdbms/queries.gen.go b/store/adapters/rdbms/queries.gen.go index fcda31fab..8aab1154b 100644 --- a/store/adapters/rdbms/queries.gen.go +++ b/store/adapters/rdbms/queries.gen.go @@ -2392,7 +2392,7 @@ var ( // federationExposedModuleTable represents federationExposedModules store table // // This value is auto-generated - federationExposedModuleTable = goqu.T("federation_exposed_module") + federationExposedModuleTable = goqu.T("federation_module_exposed") // federationExposedModuleSelectQuery assembles select query for fetching federationExposedModules // @@ -2402,9 +2402,9 @@ var ( "id", "handle", "name", - "node_id", - "compose_module_id", - "compose_namespace_id", + "rel_node", + "rel_compose_module", + "rel_compose_namespace", "fields", "created_at", "updated_at", @@ -2421,19 +2421,19 @@ var ( federationExposedModuleInsertQuery = func(d goqu.DialectWrapper, res *federationType.ExposedModule) *goqu.InsertDataset { return d.Insert(federationExposedModuleTable). Rows(goqu.Record{ - "id": res.ID, - "handle": res.Handle, - "name": res.Name, - "node_id": res.NodeID, - "compose_module_id": res.ComposeModuleID, - "compose_namespace_id": res.ComposeNamespaceID, - "fields": res.Fields, - "created_at": res.CreatedAt, - "updated_at": res.UpdatedAt, - "deleted_at": res.DeletedAt, - "created_by": res.CreatedBy, - "updated_by": res.UpdatedBy, - "deleted_by": res.DeletedBy, + "id": res.ID, + "handle": res.Handle, + "name": res.Name, + "rel_node": res.NodeID, + "rel_compose_module": res.ComposeModuleID, + "rel_compose_namespace": res.ComposeNamespaceID, + "fields": res.Fields, + "created_at": res.CreatedAt, + "updated_at": res.UpdatedAt, + "deleted_at": res.DeletedAt, + "created_by": res.CreatedBy, + "updated_by": res.UpdatedBy, + "deleted_by": res.DeletedBy, }) } @@ -2447,18 +2447,18 @@ var ( OnConflict( goqu.DoUpdate(target[1:], goqu.Record{ - "handle": res.Handle, - "name": res.Name, - "node_id": res.NodeID, - "compose_module_id": res.ComposeModuleID, - "compose_namespace_id": res.ComposeNamespaceID, - "fields": res.Fields, - "created_at": res.CreatedAt, - "updated_at": res.UpdatedAt, - "deleted_at": res.DeletedAt, - "created_by": res.CreatedBy, - "updated_by": res.UpdatedBy, - "deleted_by": res.DeletedBy, + "handle": res.Handle, + "name": res.Name, + "rel_node": res.NodeID, + "rel_compose_module": res.ComposeModuleID, + "rel_compose_namespace": res.ComposeNamespaceID, + "fields": res.Fields, + "created_at": res.CreatedAt, + "updated_at": res.UpdatedAt, + "deleted_at": res.DeletedAt, + "created_by": res.CreatedBy, + "updated_by": res.UpdatedBy, + "deleted_by": res.DeletedBy, }, ), ) @@ -2470,18 +2470,18 @@ var ( federationExposedModuleUpdateQuery = func(d goqu.DialectWrapper, res *federationType.ExposedModule) *goqu.UpdateDataset { return d.Update(federationExposedModuleTable). Set(goqu.Record{ - "handle": res.Handle, - "name": res.Name, - "node_id": res.NodeID, - "compose_module_id": res.ComposeModuleID, - "compose_namespace_id": res.ComposeNamespaceID, - "fields": res.Fields, - "created_at": res.CreatedAt, - "updated_at": res.UpdatedAt, - "deleted_at": res.DeletedAt, - "created_by": res.CreatedBy, - "updated_by": res.UpdatedBy, - "deleted_by": res.DeletedBy, + "handle": res.Handle, + "name": res.Name, + "rel_node": res.NodeID, + "rel_compose_module": res.ComposeModuleID, + "rel_compose_namespace": res.ComposeNamespaceID, + "fields": res.Fields, + "created_at": res.CreatedAt, + "updated_at": res.UpdatedAt, + "deleted_at": res.DeletedAt, + "created_by": res.CreatedBy, + "updated_by": res.UpdatedBy, + "deleted_by": res.DeletedBy, }). Where(federationExposedModulePrimaryKeys(res)) } @@ -2812,7 +2812,7 @@ var ( // federationSharedModuleTable represents federationSharedModules store table // // This value is auto-generated - federationSharedModuleTable = goqu.T("federation_shared_module") + federationSharedModuleTable = goqu.T("federation_module_shared") // federationSharedModuleSelectQuery assembles select query for fetching federationSharedModules // @@ -2821,9 +2821,9 @@ var ( return d.Select( "id", "handle", - "node_id", + "rel_node", "name", - "external_federation_module_id", + "xref_module", "fields", "created_at", "updated_at", @@ -2840,18 +2840,18 @@ var ( federationSharedModuleInsertQuery = func(d goqu.DialectWrapper, res *federationType.SharedModule) *goqu.InsertDataset { return d.Insert(federationSharedModuleTable). Rows(goqu.Record{ - "id": res.ID, - "handle": res.Handle, - "node_id": res.NodeID, - "name": res.Name, - "external_federation_module_id": res.ExternalFederationModuleID, - "fields": res.Fields, - "created_at": res.CreatedAt, - "updated_at": res.UpdatedAt, - "deleted_at": res.DeletedAt, - "created_by": res.CreatedBy, - "updated_by": res.UpdatedBy, - "deleted_by": res.DeletedBy, + "id": res.ID, + "handle": res.Handle, + "rel_node": res.NodeID, + "name": res.Name, + "xref_module": res.ExternalFederationModuleID, + "fields": res.Fields, + "created_at": res.CreatedAt, + "updated_at": res.UpdatedAt, + "deleted_at": res.DeletedAt, + "created_by": res.CreatedBy, + "updated_by": res.UpdatedBy, + "deleted_by": res.DeletedBy, }) } @@ -2865,17 +2865,17 @@ var ( OnConflict( goqu.DoUpdate(target[1:], goqu.Record{ - "handle": res.Handle, - "node_id": res.NodeID, - "name": res.Name, - "external_federation_module_id": res.ExternalFederationModuleID, - "fields": res.Fields, - "created_at": res.CreatedAt, - "updated_at": res.UpdatedAt, - "deleted_at": res.DeletedAt, - "created_by": res.CreatedBy, - "updated_by": res.UpdatedBy, - "deleted_by": res.DeletedBy, + "handle": res.Handle, + "rel_node": res.NodeID, + "name": res.Name, + "xref_module": res.ExternalFederationModuleID, + "fields": res.Fields, + "created_at": res.CreatedAt, + "updated_at": res.UpdatedAt, + "deleted_at": res.DeletedAt, + "created_by": res.CreatedBy, + "updated_by": res.UpdatedBy, + "deleted_by": res.DeletedBy, }, ), ) @@ -2887,17 +2887,17 @@ var ( federationSharedModuleUpdateQuery = func(d goqu.DialectWrapper, res *federationType.SharedModule) *goqu.UpdateDataset { return d.Update(federationSharedModuleTable). Set(goqu.Record{ - "handle": res.Handle, - "node_id": res.NodeID, - "name": res.Name, - "external_federation_module_id": res.ExternalFederationModuleID, - "fields": res.Fields, - "created_at": res.CreatedAt, - "updated_at": res.UpdatedAt, - "deleted_at": res.DeletedAt, - "created_by": res.CreatedBy, - "updated_by": res.UpdatedBy, - "deleted_by": res.DeletedBy, + "handle": res.Handle, + "rel_node": res.NodeID, + "name": res.Name, + "xref_module": res.ExternalFederationModuleID, + "fields": res.Fields, + "created_at": res.CreatedAt, + "updated_at": res.UpdatedAt, + "deleted_at": res.DeletedAt, + "created_by": res.CreatedBy, + "updated_by": res.UpdatedBy, + "deleted_by": res.DeletedBy, }). Where(federationSharedModulePrimaryKeys(res)) } diff --git a/store/adapters/rdbms/rdbms.gen.go b/store/adapters/rdbms/rdbms.gen.go index ef08de02b..f55e91779 100644 --- a/store/adapters/rdbms/rdbms.gen.go +++ b/store/adapters/rdbms/rdbms.gen.go @@ -175,7 +175,7 @@ func (s Store) QueryActionlogs( var ( set = make([]*actionlogType.Action, 0, DefaultSliceCapacity) res *actionlogType.Action - aux auxActionlog + aux *auxActionlog rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -239,6 +239,7 @@ func (s Store) QueryActionlogs( return } + aux = new(auxActionlog) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for Actionlog: %w", err) return @@ -628,7 +629,7 @@ func (s Store) QueryApigwFilters( set = make([]*systemType.ApigwFilter, 0, DefaultSliceCapacity) res *systemType.ApigwFilter - aux auxApigwFilter + aux *auxApigwFilter rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -701,6 +702,7 @@ func (s Store) QueryApigwFilters( return } + aux = new(auxApigwFilter) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for ApigwFilter: %w", err) return @@ -1149,7 +1151,7 @@ func (s Store) QueryApigwRoutes( set = make([]*systemType.ApigwRoute, 0, DefaultSliceCapacity) res *systemType.ApigwRoute - aux auxApigwRoute + aux *auxApigwRoute rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -1222,6 +1224,7 @@ func (s Store) QueryApigwRoutes( return } + aux = new(auxApigwRoute) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for ApigwRoute: %w", err) return @@ -1674,7 +1677,7 @@ func (s Store) QueryApplications( set = make([]*systemType.Application, 0, DefaultSliceCapacity) res *systemType.Application - aux auxApplication + aux *auxApplication rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -1747,6 +1750,7 @@ func (s Store) QueryApplications( return } + aux = new(auxApplication) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for Application: %w", err) return @@ -2157,7 +2161,7 @@ func (s Store) QueryAttachments( set = make([]*systemType.Attachment, 0, DefaultSliceCapacity) res *systemType.Attachment - aux auxAttachment + aux *auxAttachment rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -2230,6 +2234,7 @@ func (s Store) QueryAttachments( return } + aux = new(auxAttachment) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for Attachment: %w", err) return @@ -2638,7 +2643,7 @@ func (s Store) QueryAuthClients( set = make([]*systemType.AuthClient, 0, DefaultSliceCapacity) res *systemType.AuthClient - aux auxAuthClient + aux *auxAuthClient rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -2711,6 +2716,7 @@ func (s Store) QueryAuthClients( return } + aux = new(auxAuthClient) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for AuthClient: %w", err) return @@ -3037,7 +3043,7 @@ func (s Store) QueryAuthConfirmedClients( var ( set = make([]*systemType.AuthConfirmedClient, 0, DefaultSliceCapacity) res *systemType.AuthConfirmedClient - aux auxAuthConfirmedClient + aux *auxAuthConfirmedClient rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -3089,6 +3095,7 @@ func (s Store) QueryAuthConfirmedClients( return } + aux = new(auxAuthConfirmedClient) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for AuthConfirmedClient: %w", err) return @@ -3327,7 +3334,7 @@ func (s Store) QueryAuthOa2tokens( var ( set = make([]*systemType.AuthOa2token, 0, DefaultSliceCapacity) res *systemType.AuthOa2token - aux auxAuthOa2token + aux *auxAuthOa2token rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -3379,6 +3386,7 @@ func (s Store) QueryAuthOa2tokens( return } + aux = new(auxAuthOa2token) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for AuthOa2token: %w", err) return @@ -3730,7 +3738,7 @@ func (s Store) QueryAuthSessions( var ( set = make([]*systemType.AuthSession, 0, DefaultSliceCapacity) res *systemType.AuthSession - aux auxAuthSession + aux *auxAuthSession rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -3782,6 +3790,7 @@ func (s Store) QueryAuthSessions( return } + aux = new(auxAuthSession) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for AuthSession: %w", err) return @@ -4176,7 +4185,7 @@ func (s Store) QueryAutomationSessions( set = make([]*automationType.Session, 0, DefaultSliceCapacity) res *automationType.Session - aux auxAutomationSession + aux *auxAutomationSession rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -4249,6 +4258,7 @@ func (s Store) QueryAutomationSessions( return } + aux = new(auxAutomationSession) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for AutomationSession: %w", err) return @@ -4663,7 +4673,7 @@ func (s Store) QueryAutomationTriggers( set = make([]*automationType.Trigger, 0, DefaultSliceCapacity) res *automationType.Trigger - aux auxAutomationTrigger + aux *auxAutomationTrigger rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -4736,6 +4746,7 @@ func (s Store) QueryAutomationTriggers( return } + aux = new(auxAutomationTrigger) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for AutomationTrigger: %w", err) return @@ -5146,7 +5157,7 @@ func (s Store) QueryAutomationWorkflows( set = make([]*automationType.Workflow, 0, DefaultSliceCapacity) res *automationType.Workflow - aux auxAutomationWorkflow + aux *auxAutomationWorkflow rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -5219,6 +5230,7 @@ func (s Store) QueryAutomationWorkflows( return } + aux = new(auxAutomationWorkflow) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for AutomationWorkflow: %w", err) return @@ -5703,7 +5715,7 @@ func (s Store) QueryComposeAttachments( set = make([]*composeType.Attachment, 0, DefaultSliceCapacity) res *composeType.Attachment - aux auxComposeAttachment + aux *auxComposeAttachment rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -5776,6 +5788,7 @@ func (s Store) QueryComposeAttachments( return } + aux = new(auxComposeAttachment) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for ComposeAttachment: %w", err) return @@ -6184,7 +6197,7 @@ func (s Store) QueryComposeCharts( set = make([]*composeType.Chart, 0, DefaultSliceCapacity) res *composeType.Chart - aux auxComposeChart + aux *auxComposeChart rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -6257,6 +6270,7 @@ func (s Store) QueryComposeCharts( return } + aux = new(auxComposeChart) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for ComposeChart: %w", err) return @@ -6713,7 +6727,7 @@ func (s Store) QueryComposeModules( set = make([]*composeType.Module, 0, DefaultSliceCapacity) res *composeType.Module - aux auxComposeModule + aux *auxComposeModule rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -6786,6 +6800,7 @@ func (s Store) QueryComposeModules( return } + aux = new(auxComposeModule) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for ComposeModule: %w", err) return @@ -7153,7 +7168,7 @@ func (s Store) QueryComposeModuleFields( var ( set = make([]*composeType.ModuleField, 0, DefaultSliceCapacity) res *composeType.ModuleField - aux auxComposeModuleField + aux *auxComposeModuleField rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -7205,6 +7220,7 @@ func (s Store) QueryComposeModuleFields( return } + aux = new(auxComposeModuleField) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for ComposeModuleField: %w", err) return @@ -7625,7 +7641,7 @@ func (s Store) QueryComposeNamespaces( set = make([]*composeType.Namespace, 0, DefaultSliceCapacity) res *composeType.Namespace - aux auxComposeNamespace + aux *auxComposeNamespace rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -7698,6 +7714,7 @@ func (s Store) QueryComposeNamespaces( return } + aux = new(auxComposeNamespace) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for ComposeNamespace: %w", err) return @@ -8176,7 +8193,7 @@ func (s Store) QueryComposePages( set = make([]*composeType.Page, 0, DefaultSliceCapacity) res *composeType.Page - aux auxComposePage + aux *auxComposePage rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -8249,6 +8266,7 @@ func (s Store) QueryComposePages( return } + aux = new(auxComposePage) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for ComposePage: %w", err) return @@ -8747,7 +8765,7 @@ func (s Store) QueryComposeRecords( set = make([]*composeType.Record, 0, DefaultSliceCapacity) res *composeType.Record - aux auxComposeRecord + aux *auxComposeRecord rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -8820,6 +8838,7 @@ func (s Store) QueryComposeRecords( return } + aux = new(auxComposeRecord) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for ComposeRecord: %w", err) return @@ -9069,7 +9088,7 @@ func (s Store) QueryComposeRecordValues( var ( set = make([]*composeType.RecordValue, 0, DefaultSliceCapacity) res *composeType.RecordValue - aux auxComposeRecordValue + aux *auxComposeRecordValue rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -9121,6 +9140,7 @@ func (s Store) QueryComposeRecordValues( return } + aux = new(auxComposeRecordValue) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for ComposeRecordValue: %w", err) return @@ -9325,7 +9345,7 @@ func (s Store) QueryCredentials( var ( set = make([]*systemType.Credential, 0, DefaultSliceCapacity) res *systemType.Credential - aux auxCredential + aux *auxCredential rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -9377,6 +9397,7 @@ func (s Store) QueryCredentials( return } + aux = new(auxCredential) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for Credential: %w", err) return @@ -9785,7 +9806,7 @@ func (s Store) QueryFederationExposedModules( set = make([]*federationType.ExposedModule, 0, DefaultSliceCapacity) res *federationType.ExposedModule - aux auxFederationExposedModule + aux *auxFederationExposedModule rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -9858,6 +9879,7 @@ func (s Store) QueryFederationExposedModules( return } + aux = new(auxFederationExposedModule) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for FederationExposedModule: %w", err) return @@ -10270,7 +10292,7 @@ func (s Store) QueryFederationModuleMappings( set = make([]*federationType.ModuleMapping, 0, DefaultSliceCapacity) res *federationType.ModuleMapping - aux auxFederationModuleMapping + aux *auxFederationModuleMapping rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -10343,6 +10365,7 @@ func (s Store) QueryFederationModuleMappings( return } + aux = new(auxFederationModuleMapping) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for FederationModuleMapping: %w", err) return @@ -10598,7 +10621,7 @@ func (s Store) QueryFederationNodes( set = make([]*federationType.Node, 0, DefaultSliceCapacity) res *federationType.Node - aux auxFederationNode + aux *auxFederationNode rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -10650,6 +10673,7 @@ func (s Store) QueryFederationNodes( return } + aux = new(auxFederationNode) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for FederationNode: %w", err) return @@ -11141,7 +11165,7 @@ func (s Store) QueryFederationNodeSyncs( set = make([]*federationType.NodeSync, 0, DefaultSliceCapacity) res *federationType.NodeSync - aux auxFederationNodeSync + aux *auxFederationNodeSync rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -11214,6 +11238,7 @@ func (s Store) QueryFederationNodeSyncs( return } + aux = new(auxFederationNodeSync) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for FederationNodeSync: %w", err) return @@ -11662,7 +11687,7 @@ func (s Store) QueryFederationSharedModules( set = make([]*federationType.SharedModule, 0, DefaultSliceCapacity) res *federationType.SharedModule - aux auxFederationSharedModule + aux *auxFederationSharedModule rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -11735,6 +11760,7 @@ func (s Store) QueryFederationSharedModules( return } + aux = new(auxFederationSharedModule) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for FederationSharedModule: %w", err) return @@ -11989,7 +12015,7 @@ func (s Store) QueryFlags( var ( set = make([]*flagType.Flag, 0, DefaultSliceCapacity) res *flagType.Flag - aux auxFlag + aux *auxFlag rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -12041,6 +12067,7 @@ func (s Store) QueryFlags( return } + aux = new(auxFlag) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for Flag: %w", err) return @@ -12295,7 +12322,7 @@ func (s Store) QueryLabels( var ( set = make([]*labelsType.Label, 0, DefaultSliceCapacity) res *labelsType.Label - aux auxLabel + aux *auxLabel rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -12347,6 +12374,7 @@ func (s Store) QueryLabels( return } + aux = new(auxLabel) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for Label: %w", err) return @@ -12752,7 +12780,7 @@ func (s Store) QueryQueues( set = make([]*systemType.Queue, 0, DefaultSliceCapacity) res *systemType.Queue - aux auxQueue + aux *auxQueue rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -12825,6 +12853,7 @@ func (s Store) QueryQueues( return } + aux = new(auxQueue) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for Queue: %w", err) return @@ -13271,7 +13300,7 @@ func (s Store) QueryQueueMessages( var ( set = make([]*systemType.QueueMessage, 0, DefaultSliceCapacity) res *systemType.QueueMessage - aux auxQueueMessage + aux *auxQueueMessage rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -13344,6 +13373,7 @@ func (s Store) QueryQueueMessages( return } + aux = new(auxQueueMessage) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for QueueMessage: %w", err) return @@ -13535,7 +13565,7 @@ func (s Store) QueryRbacRules( var ( set = make([]*rbacType.Rule, 0, DefaultSliceCapacity) res *rbacType.Rule - aux auxRbacRule + aux *auxRbacRule rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -13587,6 +13617,7 @@ func (s Store) QueryRbacRules( return } + aux = new(auxRbacRule) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for RbacRule: %w", err) return @@ -13950,7 +13981,7 @@ func (s Store) QueryReminders( set = make([]*systemType.Reminder, 0, DefaultSliceCapacity) res *systemType.Reminder - aux auxReminder + aux *auxReminder rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -14023,6 +14054,7 @@ func (s Store) QueryReminders( return } + aux = new(auxReminder) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for Reminder: %w", err) return @@ -14443,7 +14475,7 @@ func (s Store) QueryReports( set = make([]*systemType.Report, 0, DefaultSliceCapacity) res *systemType.Report - aux auxReport + aux *auxReport rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -14516,6 +14548,7 @@ func (s Store) QueryReports( return } + aux = new(auxReport) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for Report: %w", err) return @@ -14837,7 +14870,7 @@ func (s Store) QueryResourceActivitys( var ( set = make([]*discoveryType.ResourceActivity, 0, DefaultSliceCapacity) res *discoveryType.ResourceActivity - aux auxResourceActivity + aux *auxResourceActivity rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -14889,6 +14922,7 @@ func (s Store) QueryResourceActivitys( return } + aux = new(auxResourceActivity) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for ResourceActivity: %w", err) return @@ -15236,7 +15270,7 @@ func (s Store) QueryResourceTranslations( var ( set = make([]*systemType.ResourceTranslation, 0, DefaultSliceCapacity) res *systemType.ResourceTranslation - aux auxResourceTranslation + aux *auxResourceTranslation rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -15309,6 +15343,7 @@ func (s Store) QueryResourceTranslations( return } + aux = new(auxResourceTranslation) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for ResourceTranslation: %w", err) return @@ -15708,7 +15743,7 @@ func (s Store) QueryRoles( set = make([]*systemType.Role, 0, DefaultSliceCapacity) res *systemType.Role - aux auxRole + aux *auxRole rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -15781,6 +15816,7 @@ func (s Store) QueryRoles( return } + aux = new(auxRole) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for Role: %w", err) return @@ -16177,7 +16213,7 @@ func (s Store) QueryRoleMembers( var ( set = make([]*systemType.RoleMember, 0, DefaultSliceCapacity) res *systemType.RoleMember - aux auxRoleMember + aux *auxRoleMember rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -16229,6 +16265,7 @@ func (s Store) QueryRoleMembers( return } + aux = new(auxRoleMember) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for RoleMember: %w", err) return @@ -16423,7 +16460,7 @@ func (s Store) QuerySettingValues( var ( set = make([]*systemType.SettingValue, 0, DefaultSliceCapacity) res *systemType.SettingValue - aux auxSettingValue + aux *auxSettingValue rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -16475,6 +16512,7 @@ func (s Store) QuerySettingValues( return } + aux = new(auxSettingValue) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for SettingValue: %w", err) return @@ -16875,7 +16913,7 @@ func (s Store) QueryTemplates( set = make([]*systemType.Template, 0, DefaultSliceCapacity) res *systemType.Template - aux auxTemplate + aux *auxTemplate rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -16948,6 +16986,7 @@ func (s Store) QueryTemplates( return } + aux = new(auxTemplate) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for Template: %w", err) return @@ -17436,7 +17475,7 @@ func (s Store) QueryUsers( set = make([]*systemType.User, 0, DefaultSliceCapacity) res *systemType.User - aux auxUser + aux *auxUser rows *sql.Rows count uint expr, tExpr []goqu.Expression @@ -17509,6 +17548,7 @@ func (s Store) QueryUsers( return } + aux = new(auxUser) if err = aux.scan(rows); err != nil { err = fmt.Errorf("could not scan rows for User: %w", err) return diff --git a/store/adapters/rdbms/tx.go b/store/adapters/rdbms/tx.go index 923bacdf3..41e51722b 100644 --- a/store/adapters/rdbms/tx.go +++ b/store/adapters/rdbms/tx.go @@ -71,12 +71,12 @@ func tx(ctx context.Context, dbCandidate interface{}, cfg *Config, txOpt *sql.Tx return lastTaskErr } - // Call the the configured transaction retry error handler + // Call the configured transaction retry error handler // if this particular error should be retried or not // // We cannot generalize here because different store implementation have // different errors and we need to act accordingly - if !cfg.TxRetryErrHandler(try, lastTaskErr) { + if cfg.TxRetryErrHandler == nil || !cfg.TxRetryErrHandler(try, lastTaskErr) { return fmt.Errorf("failed to complete transaction: %w", lastTaskErr) } diff --git a/system/service/access_control.gen.go b/system/service/access_control.gen.go index e228f5efb..4528c62fb 100644 --- a/system/service/access_control.gen.go +++ b/system/service/access_control.gen.go @@ -55,33 +55,33 @@ func (svc accessControl) Effective(ctx context.Context, rr ...rbac.Resource) (ee func (svc accessControl) List() (out []map[string]string) { def := []map[string]string{ { - "type": types.ApigwRouteResourceType, - "any": types.ApigwRouteRbacResource(0), + "type": types.ApplicationResourceType, + "any": types.ApplicationRbacResource(0), "op": "read", }, { - "type": types.ApigwRouteResourceType, - "any": types.ApigwRouteRbacResource(0), + "type": types.ApplicationResourceType, + "any": types.ApplicationRbacResource(0), "op": "update", }, { - "type": types.ApigwRouteResourceType, - "any": types.ApigwRouteRbacResource(0), + "type": types.ApplicationResourceType, + "any": types.ApplicationRbacResource(0), "op": "delete", }, { - "type": types.ApplicationResourceType, - "any": types.ApplicationRbacResource(0), + "type": types.ApigwRouteResourceType, + "any": types.ApigwRouteRbacResource(0), "op": "read", }, { - "type": types.ApplicationResourceType, - "any": types.ApplicationRbacResource(0), + "type": types.ApigwRouteResourceType, + "any": types.ApigwRouteRbacResource(0), "op": "update", }, { - "type": types.ApplicationResourceType, - "any": types.ApplicationRbacResource(0), + "type": types.ApigwRouteResourceType, + "any": types.ApigwRouteRbacResource(0), "op": "delete", }, { @@ -129,6 +129,31 @@ func (svc accessControl) List() (out []map[string]string) { "any": types.QueueRbacResource(0), "op": "queue.write", }, + { + "type": types.QueueMessageResourceType, + "any": types.QueueMessageRbacResource(0), + "op": "read", + }, + { + "type": types.QueueMessageResourceType, + "any": types.QueueMessageRbacResource(0), + "op": "update", + }, + { + "type": types.QueueMessageResourceType, + "any": types.QueueMessageRbacResource(0), + "op": "delete", + }, + { + "type": types.QueueMessageResourceType, + "any": types.QueueMessageRbacResource(0), + "op": "queue.read", + }, + { + "type": types.QueueMessageResourceType, + "any": types.QueueMessageRbacResource(0), + "op": "queue.write", + }, { "type": types.ReportResourceType, "any": types.ReportRbacResource(0), @@ -422,27 +447,6 @@ func (svc accessControl) CloneRulesByRoleID(ctx context.Context, fromRoleID uint return svc.rbac.CloneRulesByRoleID(ctx, fromRoleID, toRoleID...) } -// CanReadApigwRoute checks if current user can read api gateway route -// -// This function is auto-generated -func (svc accessControl) CanReadApigwRoute(ctx context.Context, r *types.ApigwRoute) bool { - return svc.can(ctx, "read", r) -} - -// CanUpdateApigwRoute checks if current user can update api gateway route -// -// This function is auto-generated -func (svc accessControl) CanUpdateApigwRoute(ctx context.Context, r *types.ApigwRoute) bool { - return svc.can(ctx, "update", r) -} - -// CanDeleteApigwRoute checks if current user can delete api gateway route -// -// This function is auto-generated -func (svc accessControl) CanDeleteApigwRoute(ctx context.Context, r *types.ApigwRoute) bool { - return svc.can(ctx, "delete", r) -} - // CanReadApplication checks if current user can read application // // This function is auto-generated @@ -464,6 +468,27 @@ func (svc accessControl) CanDeleteApplication(ctx context.Context, r *types.Appl return svc.can(ctx, "delete", r) } +// CanReadApigwRoute checks if current user can read api gateway route +// +// This function is auto-generated +func (svc accessControl) CanReadApigwRoute(ctx context.Context, r *types.ApigwRoute) bool { + return svc.can(ctx, "read", r) +} + +// CanUpdateApigwRoute checks if current user can update api gateway route +// +// This function is auto-generated +func (svc accessControl) CanUpdateApigwRoute(ctx context.Context, r *types.ApigwRoute) bool { + return svc.can(ctx, "update", r) +} + +// CanDeleteApigwRoute checks if current user can delete api gateway route +// +// This function is auto-generated +func (svc accessControl) CanDeleteApigwRoute(ctx context.Context, r *types.ApigwRoute) bool { + return svc.can(ctx, "delete", r) +} + // CanReadAuthClient checks if current user can read authorization client // // This function is auto-generated @@ -527,6 +552,41 @@ func (svc accessControl) CanWriteQueueOnQueue(ctx context.Context, r *types.Queu return svc.can(ctx, "queue.write", r) } +// CanReadQueueMessage checks if current user can read queue +// +// This function is auto-generated +func (svc accessControl) CanReadQueueMessage(ctx context.Context, r *types.QueueMessage) bool { + return svc.can(ctx, "read", r) +} + +// CanUpdateQueueMessage checks if current user can update queue +// +// This function is auto-generated +func (svc accessControl) CanUpdateQueueMessage(ctx context.Context, r *types.QueueMessage) bool { + return svc.can(ctx, "update", r) +} + +// CanDeleteQueueMessage checks if current user can delete queue +// +// This function is auto-generated +func (svc accessControl) CanDeleteQueueMessage(ctx context.Context, r *types.QueueMessage) bool { + return svc.can(ctx, "delete", r) +} + +// CanReadQueueOnQueueMessage checks if current user can read from queue +// +// This function is auto-generated +func (svc accessControl) CanReadQueueOnQueueMessage(ctx context.Context, r *types.QueueMessage) bool { + return svc.can(ctx, "queue.read", r) +} + +// CanWriteQueueOnQueueMessage checks if current user can write to queue +// +// This function is auto-generated +func (svc accessControl) CanWriteQueueOnQueueMessage(ctx context.Context, r *types.QueueMessage) bool { + return svc.can(ctx, "queue.write", r) +} + // CanReadReport checks if current user can read report // // This function is auto-generated @@ -864,14 +924,16 @@ func (svc accessControl) CanManageResourceTranslations(ctx context.Context) bool // This function is auto-generated func rbacResourceValidator(r string, oo ...string) error { switch rbac.ResourceType(r) { - case types.ApigwRouteResourceType: - return rbacApigwRouteResourceValidator(r, oo...) case types.ApplicationResourceType: return rbacApplicationResourceValidator(r, oo...) + case types.ApigwRouteResourceType: + return rbacApigwRouteResourceValidator(r, oo...) case types.AuthClientResourceType: return rbacAuthClientResourceValidator(r, oo...) case types.QueueResourceType: return rbacQueueResourceValidator(r, oo...) + case types.QueueMessageResourceType: + return rbacQueueMessageResourceValidator(r, oo...) case types.ReportResourceType: return rbacReportResourceValidator(r, oo...) case types.RoleResourceType: @@ -892,13 +954,13 @@ func rbacResourceValidator(r string, oo ...string) error { // This function is auto-generated func rbacResourceOperations(r string) map[string]bool { switch rbac.ResourceType(r) { - case types.ApigwRouteResourceType: + case types.ApplicationResourceType: return map[string]bool{ "read": true, "update": true, "delete": true, } - case types.ApplicationResourceType: + case types.ApigwRouteResourceType: return map[string]bool{ "read": true, "update": true, @@ -919,6 +981,14 @@ func rbacResourceOperations(r string) map[string]bool { "queue.read": true, "queue.write": true, } + case types.QueueMessageResourceType: + return map[string]bool{ + "read": true, + "update": true, + "delete": true, + "queue.read": true, + "queue.write": true, + } case types.ReportResourceType: return map[string]bool{ "read": true, @@ -983,50 +1053,6 @@ func rbacResourceOperations(r string) map[string]bool { return nil } -// rbacApigwRouteResourceValidator checks validity of RBAC resource and operations -// -// Can be called without operations to check for validity of resource string only -// -// This function is auto-generated -func rbacApigwRouteResourceValidator(r string, oo ...string) error { - if !strings.HasPrefix(r, types.ApigwRouteResourceType) { - // expecting resource to always include path - return fmt.Errorf("invalid resource type") - } - - defOps := rbacResourceOperations(r) - for _, o := range oo { - if !defOps[o] { - return fmt.Errorf("invalid operation '%s' for apigwRoute resource", o) - } - } - - const sep = "/" - var ( - pp = strings.Split(strings.Trim(r[len(types.ApigwRouteResourceType):], sep), sep) - prc = []string{ - "ID", - } - ) - - if len(pp) != len(prc) { - return fmt.Errorf("invalid resource path structure") - } - - for i := 0; i < len(pp); i++ { - if pp[i] != "*" { - if i > 0 && pp[i-1] == "*" { - return fmt.Errorf("invalid path wildcard level (%d) for apigwRoute resource", i) - } - - if _, err := cast.ToUint64E(pp[i]); err != nil { - return fmt.Errorf("invalid reference for %s: '%s'", prc[i], pp[i]) - } - } - } - return nil -} - // rbacApplicationResourceValidator checks validity of RBAC resource and operations // // Can be called without operations to check for validity of resource string only @@ -1071,6 +1097,50 @@ func rbacApplicationResourceValidator(r string, oo ...string) error { return nil } +// rbacApigwRouteResourceValidator checks validity of RBAC resource and operations +// +// Can be called without operations to check for validity of resource string only +// +// This function is auto-generated +func rbacApigwRouteResourceValidator(r string, oo ...string) error { + if !strings.HasPrefix(r, types.ApigwRouteResourceType) { + // expecting resource to always include path + return fmt.Errorf("invalid resource type") + } + + defOps := rbacResourceOperations(r) + for _, o := range oo { + if !defOps[o] { + return fmt.Errorf("invalid operation '%s' for apigwRoute resource", o) + } + } + + const sep = "/" + var ( + pp = strings.Split(strings.Trim(r[len(types.ApigwRouteResourceType):], sep), sep) + prc = []string{ + "ID", + } + ) + + if len(pp) != len(prc) { + return fmt.Errorf("invalid resource path structure") + } + + for i := 0; i < len(pp); i++ { + if pp[i] != "*" { + if i > 0 && pp[i-1] == "*" { + return fmt.Errorf("invalid path wildcard level (%d) for apigwRoute resource", i) + } + + if _, err := cast.ToUint64E(pp[i]); err != nil { + return fmt.Errorf("invalid reference for %s: '%s'", prc[i], pp[i]) + } + } + } + return nil +} + // rbacAuthClientResourceValidator checks validity of RBAC resource and operations // // Can be called without operations to check for validity of resource string only @@ -1159,6 +1229,50 @@ func rbacQueueResourceValidator(r string, oo ...string) error { return nil } +// rbacQueueMessageResourceValidator checks validity of RBAC resource and operations +// +// Can be called without operations to check for validity of resource string only +// +// This function is auto-generated +func rbacQueueMessageResourceValidator(r string, oo ...string) error { + if !strings.HasPrefix(r, types.QueueMessageResourceType) { + // expecting resource to always include path + return fmt.Errorf("invalid resource type") + } + + defOps := rbacResourceOperations(r) + for _, o := range oo { + if !defOps[o] { + return fmt.Errorf("invalid operation '%s' for queueMessage resource", o) + } + } + + const sep = "/" + var ( + pp = strings.Split(strings.Trim(r[len(types.QueueMessageResourceType):], sep), sep) + prc = []string{ + "ID", + } + ) + + if len(pp) != len(prc) { + return fmt.Errorf("invalid resource path structure") + } + + for i := 0; i < len(pp); i++ { + if pp[i] != "*" { + if i > 0 && pp[i-1] == "*" { + return fmt.Errorf("invalid path wildcard level (%d) for queueMessage resource", i) + } + + if _, err := cast.ToUint64E(pp[i]); err != nil { + return fmt.Errorf("invalid reference for %s: '%s'", prc[i], pp[i]) + } + } + } + return nil +} + // rbacReportResourceValidator checks validity of RBAC resource and operations // // Can be called without operations to check for validity of resource string only diff --git a/system/types/rbac.gen.go b/system/types/rbac.gen.go index e6a57df1e..bbd55e102 100644 --- a/system/types/rbac.gen.go +++ b/system/types/rbac.gen.go @@ -24,47 +24,18 @@ var ( ) const ( - ApigwRouteResourceType = "corteza::system:apigw-route" - ApplicationResourceType = "corteza::system:application" - AuthClientResourceType = "corteza::system:auth-client" - QueueResourceType = "corteza::system:queue" - ReportResourceType = "corteza::system:report" - RoleResourceType = "corteza::system:role" - TemplateResourceType = "corteza::system:template" - UserResourceType = "corteza::system:user" - ComponentResourceType = "corteza::system" + ApplicationResourceType = "corteza::system:application" + ApigwRouteResourceType = "corteza::system:apigw-route" + AuthClientResourceType = "corteza::system:auth-client" + QueueResourceType = "corteza::system:queue" + QueueMessageResourceType = "corteza::system:queue_message" + ReportResourceType = "corteza::system:report" + RoleResourceType = "corteza::system:role" + TemplateResourceType = "corteza::system:template" + UserResourceType = "corteza::system:user" + ComponentResourceType = "corteza::system" ) -// RbacResource returns string representation of RBAC resource for ApigwRoute by calling ApigwRouteRbacResource fn -// -// RBAC resource is in the corteza::system:apigw-route/... format -// -// This function is auto-generated -func (r ApigwRoute) RbacResource() string { - return ApigwRouteRbacResource(r.ID) -} - -// ApigwRouteRbacResource returns string representation of RBAC resource for ApigwRoute -// -// RBAC resource is in the corteza::system:apigw-route/... format -// -// This function is auto-generated -func ApigwRouteRbacResource(id uint64) string { - cpts := []interface{}{ApigwRouteResourceType} - if id != 0 { - cpts = append(cpts, strconv.FormatUint(id, 10)) - } else { - cpts = append(cpts, "*") - } - - return fmt.Sprintf(ApigwRouteRbacResourceTpl(), cpts...) - -} - -func ApigwRouteRbacResourceTpl() string { - return "%s/%s" -} - // RbacResource returns string representation of RBAC resource for Application by calling ApplicationRbacResource fn // // RBAC resource is in the corteza::system:application/... format @@ -95,6 +66,36 @@ func ApplicationRbacResourceTpl() string { return "%s/%s" } +// RbacResource returns string representation of RBAC resource for ApigwRoute by calling ApigwRouteRbacResource fn +// +// RBAC resource is in the corteza::system:apigw-route/... format +// +// This function is auto-generated +func (r ApigwRoute) RbacResource() string { + return ApigwRouteRbacResource(r.ID) +} + +// ApigwRouteRbacResource returns string representation of RBAC resource for ApigwRoute +// +// RBAC resource is in the corteza::system:apigw-route/... format +// +// This function is auto-generated +func ApigwRouteRbacResource(id uint64) string { + cpts := []interface{}{ApigwRouteResourceType} + if id != 0 { + cpts = append(cpts, strconv.FormatUint(id, 10)) + } else { + cpts = append(cpts, "*") + } + + return fmt.Sprintf(ApigwRouteRbacResourceTpl(), cpts...) + +} + +func ApigwRouteRbacResourceTpl() string { + return "%s/%s" +} + // RbacResource returns string representation of RBAC resource for AuthClient by calling AuthClientRbacResource fn // // RBAC resource is in the corteza::system:auth-client/... format @@ -155,6 +156,36 @@ func QueueRbacResourceTpl() string { return "%s/%s" } +// RbacResource returns string representation of RBAC resource for QueueMessage by calling QueueMessageRbacResource fn +// +// RBAC resource is in the corteza::system:queue_message/... format +// +// This function is auto-generated +func (r QueueMessage) RbacResource() string { + return QueueMessageRbacResource(r.ID) +} + +// QueueMessageRbacResource returns string representation of RBAC resource for QueueMessage +// +// RBAC resource is in the corteza::system:queue_message/... format +// +// This function is auto-generated +func QueueMessageRbacResource(id uint64) string { + cpts := []interface{}{QueueMessageResourceType} + if id != 0 { + cpts = append(cpts, strconv.FormatUint(id, 10)) + } else { + cpts = append(cpts, "*") + } + + return fmt.Sprintf(QueueMessageRbacResourceTpl(), cpts...) + +} + +func QueueMessageRbacResourceTpl() string { + return "%s/%s" +} + // RbacResource returns string representation of RBAC resource for Report by calling ReportRbacResource fn // // RBAC resource is in the corteza::system:report/... format