MM-9849 Added tracking of which settings are set through environment variables (#8586)
* MM-9849 Added tracking of which settings are set through environment variables * Removed old version of viper * Added forked version of viper * Fixed unit tests * Fixed more unit tests * Removed copy from App.GetEnvironmentConfig
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
57ee6f505e
Коммит
0a6b96cb40
@@ -156,6 +156,10 @@ func (a *App) GetConfig() *model.Config {
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (a *App) GetEnvironmentConfig() map[string]interface{} {
|
||||
return a.EnvironmentConfig()
|
||||
}
|
||||
|
||||
func (a *App) SaveConfig(cfg *model.Config, sendConfigChangeClusterMessage bool) *model.AppError {
|
||||
oldCfg := a.Config()
|
||||
cfg.SetDefaults()
|
||||
|
||||
@@ -59,6 +59,7 @@ type App struct {
|
||||
Saml einterfaces.SamlInterface
|
||||
|
||||
config atomic.Value
|
||||
envConfig map[string]interface{}
|
||||
configFile string
|
||||
configListeners map[string]func(*model.Config, *model.Config)
|
||||
|
||||
|
||||
@@ -30,6 +30,13 @@ func (a *App) Config() *model.Config {
|
||||
return &model.Config{}
|
||||
}
|
||||
|
||||
func (a *App) EnvironmentConfig() map[string]interface{} {
|
||||
if a.envConfig != nil {
|
||||
return a.envConfig
|
||||
}
|
||||
return map[string]interface{}{}
|
||||
}
|
||||
|
||||
func (a *App) UpdateConfig(f func(*model.Config)) {
|
||||
old := a.Config()
|
||||
updated := old.Clone()
|
||||
@@ -46,7 +53,7 @@ func (a *App) PersistConfig() {
|
||||
func (a *App) LoadConfig(configFile string) *model.AppError {
|
||||
old := a.Config()
|
||||
|
||||
cfg, configPath, err := utils.LoadConfig(configFile)
|
||||
cfg, configPath, envConfig, err := utils.LoadConfig(configFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -57,6 +64,7 @@ func (a *App) LoadConfig(configFile string) *model.AppError {
|
||||
l4g.Info("Using config file at %s", configPath)
|
||||
|
||||
a.config.Store(cfg)
|
||||
a.envConfig = envConfig
|
||||
|
||||
a.siteURL = strings.TrimRight(*cfg.ServiceSettings.SiteURL, "/")
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user