MM-14145: The config store Set will now Save automatically (#10377)
* MM-14145: The config store Set will now Save automatically When UpdateConfig (and configStore.Set) is called in admin.go and config.go, commonStore.Set now takes a store-specific persist function. It uses that persist function to save the configuration automatically. Removed: Now callers do not have to call configStore.Save or app.PersistConfig, and those functions have been removed. Possible downside: this means a "failed to persist config" error can now be thrown during a app.UpdateConfig or commonStore.Set call. But considering application code never really sets a config without saving it (except in the test cases, which were testing that -- see below), it seems fine to group these responsibilities. Also removed: tests for 'set without save'. Since that can not happen anymore, the tests are not needed. * Removed Save completely, cleaned up formatting, joined save test with set tests. * fixed shadowed variable error
Этот коммит содержится в:
коммит произвёл
Jesse Hallam
родитель
06261d32ba
Коммит
8bd182c38f
@@ -226,9 +226,6 @@ func configSetCmdF(command *cobra.Command, args []string) error {
|
||||
|
||||
f := updateConfigValue(configSetting, newVal, oldConfig, newConfig)
|
||||
f(newConfig)
|
||||
if _, err := configStore.Set(newConfig); err != nil {
|
||||
return errors.Wrap(err, "failed to set config")
|
||||
}
|
||||
|
||||
// UpdateConfig above would have already fixed these invalid locales, but we check again
|
||||
// in the context of an explicit change to these parameters to avoid saving the fixed
|
||||
@@ -237,7 +234,9 @@ func configSetCmdF(command *cobra.Command, args []string) error {
|
||||
return errors.New("Invalid locale configuration")
|
||||
}
|
||||
|
||||
configStore.Save()
|
||||
if _, err := configStore.Set(newConfig); err != nil {
|
||||
return errors.Wrap(err, "failed to set config")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user