[MM-30436] Add support for configuration custom defaults (#16265)
* [MM-30436] Add support for configuration custom defaults * Addressing review comments * Addressing PR comments * Soft fail if the configuration defaults cannot be read * Directly print error in log message * Fix linter Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c82c37a36e
Коммит
6c857a4525
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
)
|
||||
|
||||
var emptyConfig, readOnlyConfig, minimalConfig, invalidConfig, fixesRequiredConfig, ldapConfig, testConfig *model.Config
|
||||
var emptyConfig, readOnlyConfig, minimalConfig, invalidConfig, fixesRequiredConfig, ldapConfig, testConfig, customConfigDefaults *model.Config
|
||||
|
||||
func init() {
|
||||
emptyConfig = &model.Config{}
|
||||
@@ -72,6 +72,14 @@ func init() {
|
||||
SiteURL: sToP("http://TestStoreNew"),
|
||||
},
|
||||
}
|
||||
customConfigDefaults = &model.Config{
|
||||
ServiceSettings: model.ServiceSettings{
|
||||
SiteURL: model.NewString("http://custom.com"),
|
||||
},
|
||||
DisplaySettings: model.DisplaySettings{
|
||||
ExperimentalTimezone: model.NewBool(false),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeConfigs(t *testing.T) {
|
||||
@@ -132,7 +140,7 @@ func TestMergeConfigs(t *testing.T) {
|
||||
func TestConfigEnvironmentOverrides(t *testing.T) {
|
||||
memstore, err := config.NewMemoryStore()
|
||||
require.NoError(t, err)
|
||||
base, err := config.NewStoreFromBacking(memstore)
|
||||
base, err := config.NewStoreFromBacking(memstore, nil)
|
||||
require.NoError(t, err)
|
||||
originalConfig := &model.Config{}
|
||||
originalConfig.ServiceSettings.SiteURL = newString("http://notoverriden.ca")
|
||||
@@ -161,7 +169,7 @@ func TestRemoveEnvironmentOverrides(t *testing.T) {
|
||||
|
||||
memstore, err := config.NewMemoryStore()
|
||||
require.NoError(t, err)
|
||||
base, err := config.NewStoreFromBacking(memstore)
|
||||
base, err := config.NewStoreFromBacking(memstore, nil)
|
||||
require.NoError(t, err)
|
||||
oldCfg := base.Get()
|
||||
assert.Equal(t, "http://overridden.ca", *oldCfg.ServiceSettings.SiteURL)
|
||||
|
||||
Ссылка в новой задаче
Block a user