From 8ac6c17ea8ba897b7bcb2624ccc2799b48a107ff Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Sun, 16 Aug 2020 14:27:42 +0200 Subject: [PATCH] Rename generated interfaces (for easier ext.) --- compose/service/service.go | 9 +++++++++ compose/service/store_interface.gen.go | 12 +++++++----- messaging/service/service.go | 9 +++++++++ messaging/service/store_interface.gen.go | 10 ++++++---- .../assets/store_interfaces_joined.gen.go.tpl | 12 +++++++----- store/bulk/bulk.go | 4 ++++ store/bulk/store_interface.gen.go | 12 +++++++----- store/tests/store_interface.gen.go | 12 +++++++----- system/service/service.go | 14 ++++++++++---- system/service/store_interface.gen.go | 12 +++++++----- tests/compose/store_interface.gen.go | 8 +++++--- tests/messaging/store_interface.gen.go | 8 +++++--- tests/system/store_interface.gen.go | 8 +++++--- 13 files changed, 88 insertions(+), 42 deletions(-) diff --git a/compose/service/service.go b/compose/service/service.go index 02a2a2dad..5c7ced655 100644 --- a/compose/service/service.go +++ b/compose/service/service.go @@ -35,6 +35,15 @@ type ( WaitFor(ctx context.Context, ev eventbus.Event) (err error) Dispatch(ctx context.Context, ev eventbus.Event) } + + // storeInterface wraps generated interfaces to enable extensions + storeInterface interface { + // Include generated interfaces + storeGeneratedInterfaces + + // And all additional required functions + // ... + } ) var ( diff --git a/compose/service/store_interface.gen.go b/compose/service/store_interface.gen.go index 7930914c1..1b9c9ad45 100644 --- a/compose/service/store_interface.gen.go +++ b/compose/service/store_interface.gen.go @@ -2,10 +2,8 @@ package service // This file is auto-generated. // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// Definitions file that controls how this file is generated: +// Template: pkg/store_interfaces_joined.gen.go.tpl +// Definitions: // - store/actionlog.yaml // - store/compose_charts.yaml // - store/compose_module_fields.yaml @@ -13,10 +11,14 @@ package service // - store/compose_namespaces.yaml // - store/compose_pages.yaml // - store/rbac_rules.yaml +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// type ( // Interface combines interfaces of all supported store interfaces - storeInterface interface { + storeGeneratedInterfaces interface { actionlogsStore composeChartsStore composeModuleFieldsStore diff --git a/messaging/service/service.go b/messaging/service/service.go index 4a29363a6..4bc05e47c 100644 --- a/messaging/service/service.go +++ b/messaging/service/service.go @@ -30,6 +30,15 @@ type ( ActionLog options.ActionLogOpt Storage options.StorageOpt } + + // storeInterface wraps generated interfaces to enable extensions + storeInterface interface { + // Include generated interfaces + storeGeneratedInterfaces + + // And all additional required functions + // ... + } ) var ( diff --git a/messaging/service/store_interface.gen.go b/messaging/service/store_interface.gen.go index d7a73ce53..70caa7d67 100644 --- a/messaging/service/store_interface.gen.go +++ b/messaging/service/store_interface.gen.go @@ -2,16 +2,18 @@ package service // This file is auto-generated. // +// Template: pkg/store_interfaces_joined.gen.go.tpl +// Definitions: +// - store/actionlog.yaml +// - store/rbac_rules.yaml +// // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // -// Definitions file that controls how this file is generated: -// - store/actionlog.yaml -// - store/rbac_rules.yaml type ( // Interface combines interfaces of all supported store interfaces - storeInterface interface { + storeGeneratedInterfaces interface { actionlogsStore rbacRulesStore } diff --git a/pkg/codegen/assets/store_interfaces_joined.gen.go.tpl b/pkg/codegen/assets/store_interfaces_joined.gen.go.tpl index 7f12bc4c4..7bb6cb085 100644 --- a/pkg/codegen/assets/store_interfaces_joined.gen.go.tpl +++ b/pkg/codegen/assets/store_interfaces_joined.gen.go.tpl @@ -2,17 +2,19 @@ package {{ .Package }} // This file is auto-generated. // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// Definitions file that controls how this file is generated: +// Template: pkg/store_interfaces_joined.gen.go.tpl +// Definitions: {{- range .Definitions }} // - {{ .Source }} {{- end }} +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// type ( // Interface combines interfaces of all supported store interfaces - storeInterface interface { + storeGeneratedInterfaces interface { {{ range .Definitions -}} {{ unpubIdent .Types.Plural }}Store {{ end }} diff --git a/store/bulk/bulk.go b/store/bulk/bulk.go index ee40f3fae..d50b9f91e 100644 --- a/store/bulk/bulk.go +++ b/store/bulk/bulk.go @@ -5,6 +5,10 @@ import ( ) type ( + storeInterface interface { + storeGeneratedInterfaces + } + Job interface { Do(ctx context.Context, s storeInterface) error } diff --git a/store/bulk/store_interface.gen.go b/store/bulk/store_interface.gen.go index 283808586..5dc153258 100644 --- a/store/bulk/store_interface.gen.go +++ b/store/bulk/store_interface.gen.go @@ -2,10 +2,8 @@ package bulk // This file is auto-generated. // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// Definitions file that controls how this file is generated: +// Template: pkg/store_interfaces_joined.gen.go.tpl +// Definitions: // - store/actionlog.yaml // - store/applications.yaml // - store/compose_charts.yaml @@ -20,10 +18,14 @@ package bulk // - store/settings.yaml // - store/system_attachments.yaml // - store/users.yaml +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// type ( // Interface combines interfaces of all supported store interfaces - storeInterface interface { + storeGeneratedInterfaces interface { actionlogsStore applicationsStore composeChartsStore diff --git a/store/tests/store_interface.gen.go b/store/tests/store_interface.gen.go index 43500f927..66f67faeb 100644 --- a/store/tests/store_interface.gen.go +++ b/store/tests/store_interface.gen.go @@ -2,10 +2,8 @@ package tests // This file is auto-generated. // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// Definitions file that controls how this file is generated: +// Template: pkg/store_interfaces_joined.gen.go.tpl +// Definitions: // - store/actionlog.yaml // - store/applications.yaml // - store/compose_charts.yaml @@ -20,10 +18,14 @@ package tests // - store/settings.yaml // - store/system_attachments.yaml // - store/users.yaml +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// type ( // Interface combines interfaces of all supported store interfaces - storeInterface interface { + storeGeneratedInterfaces interface { actionlogsStore applicationsStore composeChartsStore diff --git a/system/service/service.go b/system/service/service.go index b21d21387..2e625cc60 100644 --- a/system/service/service.go +++ b/system/service/service.go @@ -21,10 +21,6 @@ import ( ) type ( - db interface { - Transaction(callback func() error) error - } - permissionServicer interface { accessControlPermissionServicer Watch(ctx context.Context) @@ -45,6 +41,16 @@ type ( WaitFor(ctx context.Context, ev eventbus.Event) (err error) Dispatch(ctx context.Context, ev eventbus.Event) } + + // storeInterface wraps generated interfaces to enable extensions + storeInterface interface { + // Include generated interfaces + storeGeneratedInterfaces + + // And all additional required functions + AddRoleMembersByID(context.Context, uint64, ...uint64) error + CountUsers(context.Context, types.UserFilter) (uint, error) + } ) var ( diff --git a/system/service/store_interface.gen.go b/system/service/store_interface.gen.go index 914aa7de8..f5145bf47 100644 --- a/system/service/store_interface.gen.go +++ b/system/service/store_interface.gen.go @@ -2,10 +2,8 @@ package service // This file is auto-generated. // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// Definitions file that controls how this file is generated: +// Template: pkg/store_interfaces_joined.gen.go.tpl +// Definitions: // - store/actionlog.yaml // - store/applications.yaml // - store/credentials.yaml @@ -15,10 +13,14 @@ package service // - store/settings.yaml // - store/system_attachments.yaml // - store/users.yaml +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// type ( // Interface combines interfaces of all supported store interfaces - storeInterface interface { + storeGeneratedInterfaces interface { actionlogsStore applicationsStore credentialsStore diff --git a/tests/compose/store_interface.gen.go b/tests/compose/store_interface.gen.go index 723fb161b..2009fd0a0 100644 --- a/tests/compose/store_interface.gen.go +++ b/tests/compose/store_interface.gen.go @@ -2,15 +2,17 @@ package compose // This file is auto-generated. // +// Template: pkg/store_interfaces_joined.gen.go.tpl +// Definitions: +// - store/rbac_rules.yaml +// // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // -// Definitions file that controls how this file is generated: -// - store/rbac_rules.yaml type ( // Interface combines interfaces of all supported store interfaces - storeInterface interface { + storeGeneratedInterfaces interface { rbacRulesStore } ) diff --git a/tests/messaging/store_interface.gen.go b/tests/messaging/store_interface.gen.go index 088aaabea..5ea9194fc 100644 --- a/tests/messaging/store_interface.gen.go +++ b/tests/messaging/store_interface.gen.go @@ -2,15 +2,17 @@ package messaging // This file is auto-generated. // +// Template: pkg/store_interfaces_joined.gen.go.tpl +// Definitions: +// - store/rbac_rules.yaml +// // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // -// Definitions file that controls how this file is generated: -// - store/rbac_rules.yaml type ( // Interface combines interfaces of all supported store interfaces - storeInterface interface { + storeGeneratedInterfaces interface { rbacRulesStore } ) diff --git a/tests/system/store_interface.gen.go b/tests/system/store_interface.gen.go index 4c01a8243..10900f1f9 100644 --- a/tests/system/store_interface.gen.go +++ b/tests/system/store_interface.gen.go @@ -2,15 +2,17 @@ package system // This file is auto-generated. // +// Template: pkg/store_interfaces_joined.gen.go.tpl +// Definitions: +// - store/rbac_rules.yaml +// // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // -// Definitions file that controls how this file is generated: -// - store/rbac_rules.yaml type ( // Interface combines interfaces of all supported store interfaces - storeInterface interface { + storeGeneratedInterfaces interface { rbacRulesStore } )