mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-13893: refactor config (#10230)
* refactor utils/config* to config/ * pull validateLdapFilter into app * clean up Config/GetConfig/GetSanitizedConfig usage Eliminate app.GetConfig() in favour of just using app.Config() directly, but expose app.GetSanitizedConfig() for when the old behaviour was required. * web: isolate config setup * TestInvitePeopleProvider: make config explicit * regenerateClientConfig: avoid racey map access * integrate watch flag into app.ConfigFile option * make app.Option return an error * release.mk: only cp static files from config/ * release.mk: fix cp static files from config/ * api4: TestPlugin cleanup * s/c/cfg/ for clarity * fix merge conflict * testlib: allow customization of testlib driver name
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/mattermost/mattermost-server/config"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
"github.com/mattermost/mattermost-server/utils/fileutils"
|
||||
@@ -234,7 +235,7 @@ func configSetCmdF(command *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := utils.ValidateLocales(app.Config()); err != nil {
|
||||
if err := config.ValidateLocales(app.Config()); err != nil {
|
||||
return errors.New("Invalid locale configuration")
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ func InitDBCommandContext(configFileLocation string) (*app.App, error) {
|
||||
}
|
||||
model.AppErrorInit(utils.T)
|
||||
|
||||
s, err := app.NewServer(app.ConfigFile(configFileLocation))
|
||||
s, err := app.NewServer(app.ConfigFile(configFileLocation, true))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
"github.com/mattermost/mattermost-server/config"
|
||||
"github.com/mattermost/mattermost-server/utils/fileutils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -15,11 +15,11 @@ func TestPlugin(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
config := th.Config()
|
||||
*config.PluginSettings.EnableUploads = true
|
||||
*config.PluginSettings.Directory = "./test-plugins"
|
||||
*config.PluginSettings.ClientDirectory = "./test-client-plugins"
|
||||
th.SetConfig(config)
|
||||
cfg := th.Config()
|
||||
*cfg.PluginSettings.EnableUploads = true
|
||||
*cfg.PluginSettings.Directory = "./test-plugins"
|
||||
*cfg.PluginSettings.ClientDirectory = "./test-client-plugins"
|
||||
th.SetConfig(cfg)
|
||||
|
||||
os.MkdirAll("./test-plugins", os.ModePerm)
|
||||
os.MkdirAll("./test-client-plugins", os.ModePerm)
|
||||
@@ -31,12 +31,12 @@ func TestPlugin(t *testing.T) {
|
||||
th.CheckCommand(t, "plugin", "add", filepath.Join(path, "testplugin.tar.gz"))
|
||||
|
||||
th.CheckCommand(t, "plugin", "enable", "testplugin")
|
||||
cfg, _, _, err := utils.LoadConfig(th.ConfigPath())
|
||||
cfg, _, _, err := config.LoadConfig(th.ConfigPath())
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, cfg.PluginSettings.PluginStates["testplugin"].Enable, true)
|
||||
|
||||
th.CheckCommand(t, "plugin", "disable", "testplugin")
|
||||
cfg, _, _, err = utils.LoadConfig(th.ConfigPath())
|
||||
cfg, _, _, err = config.LoadConfig(th.ConfigPath())
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, cfg.PluginSettings.PluginStates["testplugin"].Enable, false)
|
||||
|
||||
|
||||
@@ -45,15 +45,12 @@ func serverCmdF(command *cobra.Command, args []string) error {
|
||||
|
||||
func runServer(configFileLocation string, disableConfigWatch bool, usedPlatform bool, interruptChan chan os.Signal) error {
|
||||
options := []app.Option{
|
||||
app.ConfigFile(configFileLocation),
|
||||
app.ConfigFile(configFileLocation, !disableConfigWatch),
|
||||
app.RunJobs,
|
||||
app.JoinCluster,
|
||||
app.StartElasticsearch,
|
||||
app.StartMetrics,
|
||||
}
|
||||
if disableConfigWatch {
|
||||
options = append(options, app.DisableConfigWatch)
|
||||
}
|
||||
server, err := app.NewServer(options...)
|
||||
if err != nil {
|
||||
mlog.Critical(err.Error())
|
||||
|
||||
Reference in New Issue
Block a user