1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-07-15 23:54:29 +02:00

reflect app <-> product package changes (#4320) (#4351)

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
This commit is contained in:
Doug Lauder
2022-12-15 11:12:13 -05:00
committed by GitHub
parent 1f39840a2e
commit be52874b17

View File

@ -10,7 +10,6 @@ import (
"github.com/mattermost/focalboard/mattermost-plugin/server/boards" "github.com/mattermost/focalboard/mattermost-plugin/server/boards"
"github.com/mattermost/focalboard/server/model" "github.com/mattermost/focalboard/server/model"
"github.com/mattermost/mattermost-server/v6/app"
mm_model "github.com/mattermost/mattermost-server/v6/model" mm_model "github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin" "github.com/mattermost/mattermost-server/v6/plugin"
"github.com/mattermost/mattermost-server/v6/product" "github.com/mattermost/mattermost-server/v6/product"
@ -25,26 +24,26 @@ const (
var errServiceTypeAssert = errors.New("type assertion failed") var errServiceTypeAssert = errors.New("type assertion failed")
func init() { func init() {
app.RegisterProduct(boardsProductName, app.ProductManifest{ product.RegisterProduct(boardsProductName, product.Manifest{
Initializer: newBoardsProduct, Initializer: newBoardsProduct,
Dependencies: map[app.ServiceKey]struct{}{ Dependencies: map[product.ServiceKey]struct{}{
app.TeamKey: {}, product.TeamKey: {},
app.ChannelKey: {}, product.ChannelKey: {},
app.UserKey: {}, product.UserKey: {},
app.PostKey: {}, product.PostKey: {},
app.BotKey: {}, product.BotKey: {},
app.ClusterKey: {}, product.ClusterKey: {},
app.ConfigKey: {}, product.ConfigKey: {},
app.LogKey: {}, product.LogKey: {},
app.LicenseKey: {}, product.LicenseKey: {},
app.FilestoreKey: {}, product.FilestoreKey: {},
app.FileInfoStoreKey: {}, product.FileInfoStoreKey: {},
app.RouterKey: {}, product.RouterKey: {},
app.CloudKey: {}, product.CloudKey: {},
app.KVStoreKey: {}, product.KVStoreKey: {},
app.StoreKey: {}, product.StoreKey: {},
app.SystemKey: {}, product.SystemKey: {},
app.PreferencesKey: {}, product.PreferencesKey: {},
}, },
}) })
} }
@ -73,120 +72,120 @@ type boardsProduct struct {
boardsApp *boards.BoardsApp boardsApp *boards.BoardsApp
} }
func newBoardsProduct(_ *app.Server, services map[app.ServiceKey]interface{}) (app.Product, error) { func newBoardsProduct(services map[product.ServiceKey]interface{}) (product.Product, error) {
boards := &boardsProduct{} boards := &boardsProduct{}
for key, service := range services { for key, service := range services {
switch key { switch key {
case app.TeamKey: case product.TeamKey:
teamService, ok := service.(product.TeamService) teamService, ok := service.(product.TeamService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.teamService = teamService boards.teamService = teamService
case app.ChannelKey: case product.ChannelKey:
channelService, ok := service.(product.ChannelService) channelService, ok := service.(product.ChannelService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.channelService = channelService boards.channelService = channelService
case app.UserKey: case product.UserKey:
userService, ok := service.(product.UserService) userService, ok := service.(product.UserService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.userService = userService boards.userService = userService
case app.PostKey: case product.PostKey:
postService, ok := service.(product.PostService) postService, ok := service.(product.PostService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.postService = postService boards.postService = postService
case app.PermissionsKey: case product.PermissionsKey:
permissionsService, ok := service.(product.PermissionService) permissionsService, ok := service.(product.PermissionService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.permissionsService = permissionsService boards.permissionsService = permissionsService
case app.BotKey: case product.BotKey:
botService, ok := service.(product.BotService) botService, ok := service.(product.BotService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.botService = botService boards.botService = botService
case app.ClusterKey: case product.ClusterKey:
clusterService, ok := service.(product.ClusterService) clusterService, ok := service.(product.ClusterService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.clusterService = clusterService boards.clusterService = clusterService
case app.ConfigKey: case product.ConfigKey:
configService, ok := service.(product.ConfigService) configService, ok := service.(product.ConfigService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.configService = configService boards.configService = configService
case app.LogKey: case product.LogKey:
logger, ok := service.(mlog.LoggerIFace) logger, ok := service.(mlog.LoggerIFace)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.logger = logger.With(mlog.String("product", boardsProductName)) boards.logger = logger.With(mlog.String("product", boardsProductName))
case app.LicenseKey: case product.LicenseKey:
licenseService, ok := service.(product.LicenseService) licenseService, ok := service.(product.LicenseService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.licenseService = licenseService boards.licenseService = licenseService
case app.FilestoreKey: case product.FilestoreKey:
filestoreService, ok := service.(product.FilestoreService) filestoreService, ok := service.(product.FilestoreService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.filestoreService = filestoreService boards.filestoreService = filestoreService
case app.FileInfoStoreKey: case product.FileInfoStoreKey:
fileInfoStoreService, ok := service.(product.FileInfoStoreService) fileInfoStoreService, ok := service.(product.FileInfoStoreService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.fileInfoStoreService = fileInfoStoreService boards.fileInfoStoreService = fileInfoStoreService
case app.RouterKey: case product.RouterKey:
routerService, ok := service.(product.RouterService) routerService, ok := service.(product.RouterService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.routerService = routerService boards.routerService = routerService
case app.CloudKey: case product.CloudKey:
cloudService, ok := service.(product.CloudService) cloudService, ok := service.(product.CloudService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.cloudService = cloudService boards.cloudService = cloudService
case app.KVStoreKey: case product.KVStoreKey:
kvStoreService, ok := service.(product.KVStoreService) kvStoreService, ok := service.(product.KVStoreService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.kvStoreService = kvStoreService boards.kvStoreService = kvStoreService
case app.StoreKey: case product.StoreKey:
storeService, ok := service.(product.StoreService) storeService, ok := service.(product.StoreService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.storeService = storeService boards.storeService = storeService
case app.SystemKey: case product.SystemKey:
systemService, ok := service.(product.SystemService) systemService, ok := service.(product.SystemService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.systemService = systemService boards.systemService = systemService
case app.PreferencesKey: case product.PreferencesKey:
preferencesService, ok := service.(product.PreferencesService) preferencesService, ok := service.(product.PreferencesService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)
} }
boards.preferencesService = preferencesService boards.preferencesService = preferencesService
case app.HooksKey: case product.HooksKey:
hooksService, ok := service.(product.HooksService) hooksService, ok := service.(product.HooksService)
if !ok { if !ok {
return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert)