Revert "config/diff: add utility function to get diffs scoped with struct tags (#20206)" (#20256)

Automatic Merge
Этот коммит содержится в:
Miguel de la Cruz
2022-05-20 23:16:24 +02:00
коммит произвёл GitHub
родитель 9a67ae9ac6
Коммит c100fc2135
4 изменённых файлов: 16 добавлений и 163 удалений

Просмотреть файл

@@ -154,13 +154,10 @@ func updateConfig(c *Context, w http.ResponseWriter, r *http.Request) {
// There are some settings that cannot be changed in a cloud env
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud {
diffs, diffErr := config.DiffTags(appCfg, cfg, "access", "cloud_restrictable")
if diffErr != nil {
c.Err = model.NewAppError("updateConfig", "api.config.update_config.diff.app_error", nil, diffErr.Error(), http.StatusInternalServerError)
return
}
if len(diffs) > 0 {
c.Err = model.NewAppError("updateConfig", "api.config.update_config.not_allowed_security.app_error", map[string]interface{}{"Name": diffs[0].Path}, "", http.StatusForbidden)
// Both of them cannot be nil since cfg.SetDefaults is called earlier for cfg,
// and appCfg is the existing earlier config and if it's nil, server sets a default value.
if *appCfg.ComplianceSettings.Directory != *cfg.ComplianceSettings.Directory {
c.Err = model.NewAppError("updateConfig", "api.config.update_config.not_allowed_security.app_error", map[string]interface{}{"Name": "ComplianceSettings.Directory"}, "", http.StatusForbidden)
return
}
}
@@ -291,13 +288,8 @@ func patchConfig(c *Context, w http.ResponseWriter, r *http.Request) {
// There are some settings that cannot be changed in a cloud env
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud {
diffs, diffErr := config.DiffTags(appCfg, cfg, "access", "cloud_restrictable")
if diffErr != nil {
c.Err = model.NewAppError("patchConfig", "api.config.update_config.diff.app_error", nil, diffErr.Error(), http.StatusInternalServerError)
return
}
if len(diffs) > 0 {
c.Err = model.NewAppError("patchConfig", "api.config.update_config.not_allowed_security.app_error", map[string]interface{}{"Name": diffs[0].Path}, "", http.StatusForbidden)
if cfg.ComplianceSettings.Directory != nil && *appCfg.ComplianceSettings.Directory != *cfg.ComplianceSettings.Directory {
c.Err = model.NewAppError("patchConfig", "api.config.update_config.not_allowed_security.app_error", map[string]interface{}{"Name": "ComplianceSettings.Directory"}, "", http.StatusForbidden)
return
}
}