* Removing some other fake apps * More FakeApp removed * Removing entirely FakeApp * Fixing some tests * Fixing get Cluster id from get plugin status * Fixing failing tests * Fixing tests * Fixing test initialization for web * Fixing InitServer for server tests * Fixing InitServer for server tests * Reverting go.sum and go.mod * Removing unneded HTMLTemplates function in App layer * Moving back some functions to its old place to easy the review * Moving back some functions to its old place to easy the review * Using the last struct2interface version * Generating store layers * Fixing merge problems * Addressing PR comments * Small fix * Fixing app tests build * Fixing tests * fixing tests * Fix tests * Fixing tests * Fixing tests * Fixing tests * Moving license to server struct * Adding some fixes to the test compilation * Fixing cluster and some jobs initialization * Fixing some license tests compilation problems * Fixing recursive cache invalidation * Regenerating app layers * Fix test compilation Co-authored-by: mattermod <mattermod@users.noreply.github.com>
52 строки
1.1 KiB
Go
52 строки
1.1 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package commands
|
|
|
|
import (
|
|
"github.com/mattermost/mattermost-server/v5/app"
|
|
"github.com/mattermost/mattermost-server/v5/model"
|
|
"github.com/mattermost/mattermost-server/v5/utils"
|
|
"github.com/mattermost/viper"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func InitDBCommandContextCobra(command *cobra.Command) (*app.App, error) {
|
|
config := viper.GetString("config")
|
|
|
|
a, err := InitDBCommandContext(config)
|
|
|
|
if err != nil {
|
|
// Returning an error just prints the usage message, so actually panic
|
|
panic(err)
|
|
}
|
|
|
|
a.InitPlugins(*a.Config().PluginSettings.Directory, *a.Config().PluginSettings.ClientDirectory)
|
|
a.DoAppMigrations()
|
|
|
|
return a, nil
|
|
}
|
|
|
|
func InitDBCommandContext(configDSN string) (*app.App, error) {
|
|
if err := utils.TranslationsPreInit(); err != nil {
|
|
return nil, err
|
|
}
|
|
model.AppErrorInit(utils.T)
|
|
|
|
s, err := app.NewServer(
|
|
app.Config(configDSN, false),
|
|
app.StartSearchEngine,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
a := app.New(app.ServerConnector(s))
|
|
|
|
if model.BuildEnterpriseReady == "true" {
|
|
a.Srv().LoadLicense()
|
|
}
|
|
|
|
return a, nil
|
|
}
|