* Testing caching for emojis * MM-10117 Add support to add/delete and activate/deactivate plugins via CLI * Removing old work * MM-10117 Moved files and addedd plugin test * MM-10117 Renamed commands to enable/disable and updated add test * MM-10117 Finished plugin test and improved error message for plugin commands * MM-10117 Fixing plugin directories for test * MM-10117 Renamed commands and updated commands to support multiple plugins * MM-10117 Updating removed to deleted textclear * MM-10117 Fixing nil pointer error for listing plugins * MM-10117 Removing fileReader close * MM-10117 Declaring error for GetPlugins * MM-10117 Removing unnecessary nil check
50 строки
1.1 KiB
Go
50 строки
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/app"
|
|
"github.com/mattermost/mattermost-server/model"
|
|
"github.com/mattermost/mattermost-server/utils"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func InitDBCommandContextCobra(command *cobra.Command) (*app.App, error) {
|
|
config, err := command.Flags().GetString("config")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
a, err := InitDBCommandContext(config)
|
|
a.InitPlugins(*a.Config().PluginSettings.Directory, *a.Config().PluginSettings.ClientDirectory)
|
|
|
|
if err != nil {
|
|
// Returning an error just prints the usage message, so actually panic
|
|
panic(err)
|
|
}
|
|
|
|
a.DoAdvancedPermissionsMigration()
|
|
a.DoEmojisPermissionsMigration()
|
|
|
|
return a, nil
|
|
}
|
|
|
|
func InitDBCommandContext(configFileLocation string) (*app.App, error) {
|
|
if err := utils.TranslationsPreInit(); err != nil {
|
|
return nil, err
|
|
}
|
|
model.AppErrorInit(utils.T)
|
|
|
|
a, err := app.New(app.ConfigFile(configFileLocation))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if model.BuildEnterpriseReady == "true" {
|
|
a.LoadLicense()
|
|
}
|
|
|
|
return a, nil
|
|
}
|