Skip to content

Commit 844adda

Browse files
committed
Remove all the deprecated setting fall backs because it reached the expected version and put a warning there
1 parent 2cd2ae0 commit 844adda

File tree

10 files changed

+43
-120
lines changed

10 files changed

+43
-120
lines changed

modules/setting/config_provider.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,16 @@ func LogStartupProblem(skip int, level log.Level, format string, args ...any) {
326326

327327
func deprecatedSetting(rootCfg ConfigProvider, oldSection, oldKey, newSection, newKey, version string) {
328328
if rootCfg.Section(oldSection).HasKey(oldKey) {
329-
LogStartupProblem(1, log.ERROR, "Deprecation: config option `[%s].%s` presents, please use `[%s].%s` instead because this fallback will be/has been removed in %s", oldSection, oldKey, newSection, newKey, version)
329+
LogStartupProblem(1, log.ERROR, "Deprecation: config option `[%s].%s` presents, please use `[%s].%s` instead because this fallback will be removed in %s", oldSection, oldKey, newSection, newKey, version)
330+
}
331+
}
332+
333+
// make linter happy when there is no deprecated setting at the moment
334+
var _ = deprecatedSetting
335+
336+
func deprecatedSettingWarning(rootCfg ConfigProvider, oldSection, oldKey, newSection, newKey, version string) {
337+
if rootCfg.Section(oldSection).HasKey(oldKey) {
338+
LogStartupProblem(1, log.ERROR, "Deprecation: config option `[%s].%s` presents, please use `[%s].%s` instead because this fallback has been removed in %s", oldSection, oldKey, newSection, newKey, version)
330339
}
331340
}
332341

modules/setting/git.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,9 @@ func loadGitFrom(rootCfg ConfigProvider) {
9797
GitConfig.SetOption("core.logAllRefUpdates", "true")
9898
GitConfig.SetOption("gc.reflogExpire", "90")
9999

100-
secGitReflog := rootCfg.Section("git.reflog")
101-
if secGitReflog.HasKey("ENABLED") {
102-
deprecatedSetting(rootCfg, "git.reflog", "ENABLED", "git.config", "core.logAllRefUpdates", "1.21")
103-
GitConfig.SetOption("core.logAllRefUpdates", secGitReflog.Key("ENABLED").In("true", []string{"true", "false"}))
104-
}
105-
if secGitReflog.HasKey("EXPIRATION") {
106-
deprecatedSetting(rootCfg, "git.reflog", "EXPIRATION", "git.config", "core.reflogExpire", "1.21")
107-
GitConfig.SetOption("gc.reflogExpire", secGitReflog.Key("EXPIRATION").String())
108-
}
100+
// keep warning here but not read the option
101+
deprecatedSettingWarning(rootCfg, "git.reflog", "ENABLED", "git.config", "core.logAllRefUpdates", "1.21")
102+
deprecatedSettingWarning(rootCfg, "git.reflog", "EXPIRATION", "git.config", "core.reflogExpire", "1.21")
109103

110104
for _, key := range secGitConfig.Keys() {
111105
GitConfig.SetOption(key.Name(), key.String())

modules/setting/lfs.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,9 @@ func loadLFSFrom(rootCfg ConfigProvider) error {
4040

4141
lfsSec, _ := rootCfg.GetSection("lfs")
4242

43-
// Specifically default PATH to LFS_CONTENT_PATH
4443
// DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version
4544
// if these are removed, the warning will not be shown
46-
deprecatedSetting(rootCfg, "server", "LFS_CONTENT_PATH", "lfs", "PATH", "v1.19.0")
47-
48-
if val := sec.Key("LFS_CONTENT_PATH").String(); val != "" {
49-
if lfsSec == nil {
50-
lfsSec = rootCfg.Section("lfs")
51-
}
52-
lfsSec.Key("PATH").MustString(val)
53-
}
45+
deprecatedSettingWarning(rootCfg, "server", "LFS_CONTENT_PATH", "lfs", "PATH", "v1.19.0")
5446

5547
var err error
5648
LFS.Storage, err = getStorage(rootCfg, "lfs", "", lfsSec)

modules/setting/log.go

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,38 +60,22 @@ func prepareLoggerConfig(rootCfg ConfigProvider) {
6060
sec.Key("logger.default.MODE").MustString(",")
6161
}
6262

63-
deprecatedSetting(rootCfg, "log", "ACCESS", "log", "logger.access.MODE", "1.21")
64-
deprecatedSetting(rootCfg, "log", "ENABLE_ACCESS_LOG", "log", "logger.access.MODE", "1.21")
65-
if val := sec.Key("ACCESS").String(); val != "" {
66-
sec.Key("logger.access.MODE").MustString(val)
67-
}
68-
if sec.HasKey("ENABLE_ACCESS_LOG") && !sec.Key("ENABLE_ACCESS_LOG").MustBool() {
69-
sec.Key("logger.access.MODE").SetValue("")
70-
}
63+
deprecatedSettingWarning(rootCfg, "log", "ACCESS", "log", "logger.access.MODE", "1.21")
64+
deprecatedSettingWarning(rootCfg, "log", "ENABLE_ACCESS_LOG", "log", "logger.access.MODE", "1.21")
65+
66+
deprecatedSettingWarning(rootCfg, "log", "ROUTER", "log", "logger.router.MODE", "1.21")
67+
deprecatedSettingWarning(rootCfg, "log", "DISABLE_ROUTER_LOG", "log", "logger.router.MODE", "1.21")
7168

72-
deprecatedSetting(rootCfg, "log", "ROUTER", "log", "logger.router.MODE", "1.21")
73-
deprecatedSetting(rootCfg, "log", "DISABLE_ROUTER_LOG", "log", "logger.router.MODE", "1.21")
74-
if val := sec.Key("ROUTER").String(); val != "" {
75-
sec.Key("logger.router.MODE").MustString(val)
76-
}
7769
if !sec.HasKey("logger.router.MODE") {
7870
sec.Key("logger.router.MODE").MustString(",") // use default logger
7971
}
80-
if sec.HasKey("DISABLE_ROUTER_LOG") && sec.Key("DISABLE_ROUTER_LOG").MustBool() {
81-
sec.Key("logger.router.MODE").SetValue("")
82-
}
8372

84-
deprecatedSetting(rootCfg, "log", "XORM", "log", "logger.xorm.MODE", "1.21")
85-
deprecatedSetting(rootCfg, "log", "ENABLE_XORM_LOG", "log", "logger.xorm.MODE", "1.21")
86-
if val := sec.Key("XORM").String(); val != "" {
87-
sec.Key("logger.xorm.MODE").MustString(val)
88-
}
73+
deprecatedSettingWarning(rootCfg, "log", "XORM", "log", "logger.xorm.MODE", "1.21")
74+
deprecatedSettingWarning(rootCfg, "log", "ENABLE_XORM_LOG", "log", "logger.xorm.MODE", "1.21")
75+
8976
if !sec.HasKey("logger.xorm.MODE") {
9077
sec.Key("logger.xorm.MODE").MustString(",") // use default logger
9178
}
92-
if sec.HasKey("ENABLE_XORM_LOG") && !sec.Key("ENABLE_XORM_LOG").MustBool() {
93-
sec.Key("logger.xorm.MODE").SetValue("")
94-
}
9579
}
9680

9781
func LogPrepareFilenameForWriter(fileName, defaultFileName string) string {

modules/setting/mailer.go

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -73,67 +73,23 @@ func loadMailerFrom(rootCfg ConfigProvider) {
7373
// Handle Deprecations and map on to new configuration
7474
// DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version
7575
// if these are removed, the warning will not be shown
76-
deprecatedSetting(rootCfg, "mailer", "MAILER_TYPE", "mailer", "PROTOCOL", "v1.19.0")
77-
if sec.HasKey("MAILER_TYPE") && !sec.HasKey("PROTOCOL") {
78-
if sec.Key("MAILER_TYPE").String() == "sendmail" {
79-
sec.Key("PROTOCOL").MustString("sendmail")
80-
}
81-
}
76+
deprecatedSettingWarning(rootCfg, "mailer", "MAILER_TYPE", "mailer", "PROTOCOL", "v1.19.0")
8277

83-
deprecatedSetting(rootCfg, "mailer", "HOST", "mailer", "SMTP_ADDR", "v1.19.0")
84-
if sec.HasKey("HOST") && !sec.HasKey("SMTP_ADDR") {
85-
givenHost := sec.Key("HOST").String()
86-
addr, port, err := net.SplitHostPort(givenHost)
87-
if err != nil && strings.Contains(err.Error(), "missing port in address") {
88-
addr = givenHost
89-
} else if err != nil {
90-
log.Fatal("Invalid mailer.HOST (%s): %v", givenHost, err)
91-
}
92-
if addr == "" {
93-
addr = "127.0.0.1"
94-
}
95-
sec.Key("SMTP_ADDR").MustString(addr)
96-
sec.Key("SMTP_PORT").MustString(port)
97-
}
78+
deprecatedSettingWarning(rootCfg, "mailer", "HOST", "mailer", "SMTP_ADDR", "v1.19.0")
9879

99-
deprecatedSetting(rootCfg, "mailer", "IS_TLS_ENABLED", "mailer", "PROTOCOL", "v1.19.0")
100-
if sec.HasKey("IS_TLS_ENABLED") && !sec.HasKey("PROTOCOL") {
101-
if sec.Key("IS_TLS_ENABLED").MustBool() {
102-
sec.Key("PROTOCOL").MustString("smtps")
103-
} else {
104-
sec.Key("PROTOCOL").MustString("smtp+starttls")
105-
}
106-
}
80+
deprecatedSettingWarning(rootCfg, "mailer", "IS_TLS_ENABLED", "mailer", "PROTOCOL", "v1.19.0")
10781

108-
deprecatedSetting(rootCfg, "mailer", "DISABLE_HELO", "mailer", "ENABLE_HELO", "v1.19.0")
109-
if sec.HasKey("DISABLE_HELO") && !sec.HasKey("ENABLE_HELO") {
110-
sec.Key("ENABLE_HELO").MustBool(!sec.Key("DISABLE_HELO").MustBool())
111-
}
82+
deprecatedSettingWarning(rootCfg, "mailer", "DISABLE_HELO", "mailer", "ENABLE_HELO", "v1.19.0")
11283

113-
deprecatedSetting(rootCfg, "mailer", "SKIP_VERIFY", "mailer", "FORCE_TRUST_SERVER_CERT", "v1.19.0")
114-
if sec.HasKey("SKIP_VERIFY") && !sec.HasKey("FORCE_TRUST_SERVER_CERT") {
115-
sec.Key("FORCE_TRUST_SERVER_CERT").MustBool(sec.Key("SKIP_VERIFY").MustBool())
116-
}
84+
deprecatedSettingWarning(rootCfg, "mailer", "SKIP_VERIFY", "mailer", "FORCE_TRUST_SERVER_CERT", "v1.19.0")
11785

118-
deprecatedSetting(rootCfg, "mailer", "USE_CERTIFICATE", "mailer", "USE_CLIENT_CERT", "v1.19.0")
119-
if sec.HasKey("USE_CERTIFICATE") && !sec.HasKey("USE_CLIENT_CERT") {
120-
sec.Key("USE_CLIENT_CERT").MustBool(sec.Key("USE_CERTIFICATE").MustBool())
121-
}
86+
deprecatedSettingWarning(rootCfg, "mailer", "USE_CERTIFICATE", "mailer", "USE_CLIENT_CERT", "v1.19.0")
12287

123-
deprecatedSetting(rootCfg, "mailer", "CERT_FILE", "mailer", "CLIENT_CERT_FILE", "v1.19.0")
124-
if sec.HasKey("CERT_FILE") && !sec.HasKey("CLIENT_CERT_FILE") {
125-
sec.Key("CERT_FILE").MustString(sec.Key("CERT_FILE").String())
126-
}
88+
deprecatedSettingWarning(rootCfg, "mailer", "CERT_FILE", "mailer", "CLIENT_CERT_FILE", "v1.19.0")
12789

128-
deprecatedSetting(rootCfg, "mailer", "KEY_FILE", "mailer", "CLIENT_KEY_FILE", "v1.19.0")
129-
if sec.HasKey("KEY_FILE") && !sec.HasKey("CLIENT_KEY_FILE") {
130-
sec.Key("KEY_FILE").MustString(sec.Key("KEY_FILE").String())
131-
}
90+
deprecatedSettingWarning(rootCfg, "mailer", "KEY_FILE", "mailer", "CLIENT_KEY_FILE", "v1.19.0")
13291

133-
deprecatedSetting(rootCfg, "mailer", "ENABLE_HTML_ALTERNATIVE", "mailer", "SEND_AS_PLAIN_TEXT", "v1.19.0")
134-
if sec.HasKey("ENABLE_HTML_ALTERNATIVE") && !sec.HasKey("SEND_AS_PLAIN_TEXT") {
135-
sec.Key("SEND_AS_PLAIN_TEXT").MustBool(!sec.Key("ENABLE_HTML_ALTERNATIVE").MustBool(false))
136-
}
92+
deprecatedSettingWarning(rootCfg, "mailer", "ENABLE_HTML_ALTERNATIVE", "mailer", "SEND_AS_PLAIN_TEXT", "v1.19.0")
13793

13894
if sec.HasKey("PROTOCOL") && sec.Key("PROTOCOL").String() == "smtp+startls" {
13995
log.Error("Deprecated fallback `[mailer]` `PROTOCOL = smtp+startls` present. Use `[mailer]` `PROTOCOL = smtp+starttls`` instead. This fallback will be removed in v1.19.0")

modules/setting/mirror.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,9 @@ var Mirror = struct {
2525
}
2626

2727
func loadMirrorFrom(rootCfg ConfigProvider) {
28-
// Handle old configuration through `[repository]` `DISABLE_MIRRORS`
29-
// - please note this was badly named and only disabled the creation of new pull mirrors
3028
// DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version
3129
// if these are removed, the warning will not be shown
32-
deprecatedSetting(rootCfg, "repository", "DISABLE_MIRRORS", "mirror", "ENABLED", "v1.19.0")
33-
if ConfigSectionKeyBool(rootCfg.Section("repository"), "DISABLE_MIRRORS") {
34-
Mirror.DisableNewPull = true
35-
}
30+
deprecatedSettingWarning(rootCfg, "repository", "DISABLE_MIRRORS", "mirror", "ENABLED", "v1.19.0")
3631

3732
if err := rootCfg.Section("mirror").MapTo(&Mirror); err != nil {
3833
log.Fatal("Failed to map Mirror settings: %v", err)

modules/setting/oauth2.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,7 @@ func loadOAuth2From(rootCfg ConfigProvider) {
121121
}
122122

123123
// Handle the rename of ENABLE to ENABLED
124-
deprecatedSetting(rootCfg, "oauth2", "ENABLE", "oauth2", "ENABLED", "v1.23.0")
125-
if sec.HasKey("ENABLE") && !sec.HasKey("ENABLED") {
126-
OAuth2.Enabled = sec.Key("ENABLE").MustBool(OAuth2.Enabled)
127-
}
124+
deprecatedSettingWarning(rootCfg, "oauth2", "ENABLE", "oauth2", "ENABLED", "v1.23.0")
128125

129126
if !filepath.IsAbs(OAuth2.JWTSigningPrivateKeyFile) {
130127
OAuth2.JWTSigningPrivateKeyFile = filepath.Join(AppDataPath, OAuth2.JWTSigningPrivateKeyFile)

modules/setting/server.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ func loadServerFrom(rootCfg ConfigProvider) {
174174
if sec.HasKey("ENABLE_ACME") {
175175
EnableAcme = sec.Key("ENABLE_ACME").MustBool(false)
176176
} else {
177-
deprecatedSetting(rootCfg, "server", "ENABLE_LETSENCRYPT", "server", "ENABLE_ACME", "v1.19.0")
178-
EnableAcme = sec.Key("ENABLE_LETSENCRYPT").MustBool(false)
177+
deprecatedSettingWarning(rootCfg, "server", "ENABLE_LETSENCRYPT", "server", "ENABLE_ACME", "v1.19.0")
179178
}
180179

181180
Protocol = HTTP
@@ -194,8 +193,7 @@ func loadServerFrom(rootCfg ConfigProvider) {
194193
if sec.HasKey("ACME_ACCEPTTOS") {
195194
AcmeTOS = sec.Key("ACME_ACCEPTTOS").MustBool(false)
196195
} else {
197-
deprecatedSetting(rootCfg, "server", "LETSENCRYPT_ACCEPTTOS", "server", "ACME_ACCEPTTOS", "v1.19.0")
198-
AcmeTOS = sec.Key("LETSENCRYPT_ACCEPTTOS").MustBool(false)
196+
deprecatedSettingWarning(rootCfg, "server", "LETSENCRYPT_ACCEPTTOS", "server", "ACME_ACCEPTTOS", "v1.19.0")
199197
}
200198
if !AcmeTOS {
201199
log.Fatal("ACME TOS is not accepted (ACME_ACCEPTTOS).")
@@ -204,15 +202,13 @@ func loadServerFrom(rootCfg ConfigProvider) {
204202
if sec.HasKey("ACME_DIRECTORY") {
205203
AcmeLiveDirectory = sec.Key("ACME_DIRECTORY").MustString("https")
206204
} else {
207-
deprecatedSetting(rootCfg, "server", "LETSENCRYPT_DIRECTORY", "server", "ACME_DIRECTORY", "v1.19.0")
208-
AcmeLiveDirectory = sec.Key("LETSENCRYPT_DIRECTORY").MustString("https")
205+
deprecatedSettingWarning(rootCfg, "server", "LETSENCRYPT_DIRECTORY", "server", "ACME_DIRECTORY", "v1.19.0")
209206
}
210207

211208
if sec.HasKey("ACME_EMAIL") {
212209
AcmeEmail = sec.Key("ACME_EMAIL").MustString("")
213210
} else {
214-
deprecatedSetting(rootCfg, "server", "LETSENCRYPT_EMAIL", "server", "ACME_EMAIL", "v1.19.0")
215-
AcmeEmail = sec.Key("LETSENCRYPT_EMAIL").MustString("")
211+
deprecatedSettingWarning(rootCfg, "server", "LETSENCRYPT_EMAIL", "server", "ACME_EMAIL", "v1.19.0")
216212
}
217213
if AcmeEmail == "" {
218214
log.Fatal("ACME Email is not set (ACME_EMAIL).")

modules/setting/service.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ func loadServiceFrom(rootCfg ConfigProvider) {
152152
} else {
153153
Service.RegisterManualConfirm = false
154154
}
155-
if sec.HasKey("EMAIL_DOMAIN_WHITELIST") {
156-
deprecatedSetting(rootCfg, "service", "EMAIL_DOMAIN_WHITELIST", "service", "EMAIL_DOMAIN_ALLOWLIST", "1.21")
157-
}
155+
156+
deprecatedSettingWarning(rootCfg, "service", "EMAIL_DOMAIN_WHITELIST", "service", "EMAIL_DOMAIN_ALLOWLIST", "1.21")
157+
158158
Service.EmailDomainAllowList = CompileEmailGlobList(sec, "EMAIL_DOMAIN_WHITELIST", "EMAIL_DOMAIN_ALLOWLIST")
159159
Service.EmailDomainBlockList = CompileEmailGlobList(sec, "EMAIL_DOMAIN_BLOCKLIST")
160160
Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!(Service.DisableRegistration || Service.AllowOnlyExternalRegistration))

modules/setting/task.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ func loadTaskFrom(rootCfg ConfigProvider) {
1010
taskSec := rootCfg.Section("task")
1111
queueTaskSec := rootCfg.Section("queue.task")
1212

13-
deprecatedSetting(rootCfg, "task", "QUEUE_TYPE", "queue.task", "TYPE", "v1.19.0")
14-
deprecatedSetting(rootCfg, "task", "QUEUE_CONN_STR", "queue.task", "CONN_STR", "v1.19.0")
15-
deprecatedSetting(rootCfg, "task", "QUEUE_LENGTH", "queue.task", "LENGTH", "v1.19.0")
13+
deprecatedSettingWarning(rootCfg, "task", "QUEUE_TYPE", "queue.task", "TYPE", "v1.19.0")
14+
deprecatedSettingWarning(rootCfg, "task", "QUEUE_CONN_STR", "queue.task", "CONN_STR", "v1.19.0")
15+
deprecatedSettingWarning(rootCfg, "task", "QUEUE_LENGTH", "queue.task", "LENGTH", "v1.19.0")
1616

1717
switch taskSec.Key("QUEUE_TYPE").MustString("channel") {
1818
case "channel":

0 commit comments

Comments
 (0)