Skip to content

Commit 1d98d20

Browse files
Gustedzeripath
Gusted
andauthored
Enable deprecation error for v1.17.0 (#18341)
Co-authored-by: Andrew Thornton <[email protected]>
1 parent 16d378f commit 1d98d20

File tree

10 files changed

+84
-52
lines changed

10 files changed

+84
-52
lines changed

modules/indexer/issues/indexer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func InitIssueIndexer(syncReindex bool) {
110110
return
111111
}
112112

113-
iData := make([]*IndexerData, 0, setting.Indexer.IssueQueueBatchNumber)
113+
iData := make([]*IndexerData, 0, len(data))
114114
for _, datum := range data {
115115
indexerData, ok := datum.(*IndexerData)
116116
if !ok {

modules/indexer/issues/indexer_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ func TestBleveSearchIssues(t *testing.T) {
3434
assert.Fail(t, "Unable to create temporary directory: %v", err)
3535
return
3636
}
37-
oldQueueDir := setting.Indexer.IssueQueueDir
37+
38+
setting.Cfg.Section("queue.issue_indexer").Key("DATADIR").MustString(path.Join(tmpIndexerDir, "issues.queue"))
39+
3840
oldIssuePath := setting.Indexer.IssuePath
39-
setting.Indexer.IssueQueueDir = path.Join(tmpIndexerDir, "issues.queue")
4041
setting.Indexer.IssuePath = path.Join(tmpIndexerDir, "issues.queue")
4142
defer func() {
42-
setting.Indexer.IssueQueueDir = oldQueueDir
4343
setting.Indexer.IssuePath = oldIssuePath
4444
util.RemoveAll(tmpIndexerDir)
4545
}()

modules/setting/indexer.go

+11-23
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,20 @@ import (
1414
"github.com/gobwas/glob"
1515
)
1616

17-
// enumerates all the indexer queue types
18-
const (
19-
LevelQueueType = "levelqueue"
20-
ChannelQueueType = "channel"
21-
RedisQueueType = "redis"
22-
)
23-
2417
var (
2518
// Indexer settings
2619
Indexer = struct {
27-
IssueType string
28-
IssuePath string
29-
IssueConnStr string
30-
IssueIndexerName string
31-
IssueQueueType string // DEPRECATED - replaced by queue.issue_indexer
32-
IssueQueueDir string // DEPRECATED - replaced by queue.issue_indexer
33-
IssueQueueConnStr string // DEPRECATED - replaced by queue.issue_indexer
34-
IssueQueueBatchNumber int // DEPRECATED - replaced by queue.issue_indexer
35-
StartupTimeout time.Duration
20+
IssueType string
21+
IssuePath string
22+
IssueConnStr string
23+
IssueIndexerName string
24+
StartupTimeout time.Duration
3625

3726
RepoIndexerEnabled bool
3827
RepoType string
3928
RepoPath string
4029
RepoConnStr string
4130
RepoIndexerName string
42-
UpdateQueueLength int // DEPRECATED - replaced by queue.issue_indexer
4331
MaxIndexerFileSize int64
4432
IncludePatterns []glob.Glob
4533
ExcludePatterns []glob.Glob
@@ -49,7 +37,6 @@ var (
4937
IssuePath: "indexers/issues.bleve",
5038
IssueConnStr: "",
5139
IssueIndexerName: "gitea_issues",
52-
IssueQueueType: LevelQueueType,
5340

5441
RepoIndexerEnabled: false,
5542
RepoType: "bleve",
@@ -72,11 +59,12 @@ func newIndexerService() {
7259
Indexer.IssueIndexerName = sec.Key("ISSUE_INDEXER_NAME").MustString(Indexer.IssueIndexerName)
7360

7461
// The following settings are deprecated and can be overridden by settings in [queue] or [queue.issue_indexer]
75-
Indexer.IssueQueueType = sec.Key("ISSUE_INDEXER_QUEUE_TYPE").MustString("")
76-
Indexer.IssueQueueDir = filepath.ToSlash(sec.Key("ISSUE_INDEXER_QUEUE_DIR").MustString(""))
77-
Indexer.IssueQueueConnStr = sec.Key("ISSUE_INDEXER_QUEUE_CONN_STR").MustString("")
78-
Indexer.IssueQueueBatchNumber = sec.Key("ISSUE_INDEXER_QUEUE_BATCH_NUMBER").MustInt(0)
79-
Indexer.UpdateQueueLength = sec.Key("UPDATE_BUFFER_LEN").MustInt(0)
62+
// FIXME: DEPRECATED to be removed in v1.18.0
63+
deprecatedSetting("indexer", "ISSUE_INDEXER_QUEUE_TYPE", "queue.issue_indexer", "TYPE")
64+
deprecatedSetting("indexer", "ISSUE_INDEXER_QUEUE_DIR", "queue.issue_indexer", "DATADIR")
65+
deprecatedSetting("indexer", "ISSUE_INDEXER_QUEUE_CONN_STR", "queue.issue_indexer", "CONN_STR")
66+
deprecatedSetting("indexer", "ISSUE_INDEXER_QUEUE_BATCH_NUMBER", "queue.issue_indexer", "BATCH_LENGTH")
67+
deprecatedSetting("indexer", "UPDATE_BUFFER_LEN", "queue.issue_indexer", "LENGTH")
8068

8169
Indexer.RepoIndexerEnabled = sec.Key("REPO_INDEXER_ENABLED").MustBool(false)
8270
Indexer.RepoType = sec.Key("REPO_INDEXER_TYPE").MustString("bleve")

modules/setting/lfs.go

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ func newLFSService() {
3636
storageType := lfsSec.Key("STORAGE_TYPE").MustString("")
3737

3838
// Specifically default PATH to LFS_CONTENT_PATH
39+
//FIXME: DEPRECATED to be removed in v1.18.0
40+
deprecatedSetting("server", "LFS_CONTENT_PATH", "lfs", "PATH")
3941
lfsSec.Key("PATH").MustString(
4042
sec.Key("LFS_CONTENT_PATH").String())
4143

modules/setting/mailer.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@ func newMailService() {
7979
MailService.From = sec.Key("FROM").MustString(MailService.User)
8080
MailService.EnvelopeFrom = sec.Key("ENVELOPE_FROM").MustString("")
8181

82+
// FIXME: DEPRECATED to be removed in v1.18.0
83+
deprecatedSetting("mailer", "ENABLE_HTML_ALTERNATIVE", "mailer", "SEND_AS_PLAIN_TEXT")
8284
if sec.HasKey("ENABLE_HTML_ALTERNATIVE") {
83-
log.Warn("ENABLE_HTML_ALTERNATIVE is deprecated, use SEND_AS_PLAIN_TEXT")
8485
MailService.SendAsPlainText = !sec.Key("ENABLE_HTML_ALTERNATIVE").MustBool(false)
8586
}
8687

88+
// FIXME: DEPRECATED to be removed in v1.18.0
89+
deprecatedSetting("mailer", "USE_SENDMAIL", "mailer", "MAILER_TYPE")
8790
if sec.HasKey("USE_SENDMAIL") {
88-
log.Warn("USE_SENDMAIL is deprecated, use MAILER_TYPE=sendmail")
8991
if MailService.MailerType == "" && sec.Key("USE_SENDMAIL").MustBool(false) {
9092
MailService.MailerType = "sendmail"
9193
}

modules/setting/mirror.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ var (
3030
func newMirror() {
3131
// Handle old configuration through `[repository]` `DISABLE_MIRRORS`
3232
// - please note this was badly named and only disabled the creation of new pull mirrors
33+
// FIXME: DEPRECATED to be removed in v1.18.0
34+
deprecatedSetting("repository", "DISABLE_MIRRORS", "mirror", "ENABLED")
3335
if Cfg.Section("repository").Key("DISABLE_MIRRORS").MustBool(false) {
34-
log.Warn("Deprecated DISABLE_MIRRORS config is used, please change your config and use the options within the [mirror] section")
35-
// TODO: enable on v1.17.0: log.Error("Deprecated fallback used, will be removed in v1.18.0")
3636
Mirror.DisableNewPull = true
3737
}
38+
3839
if err := Cfg.Section("mirror").MapTo(&Mirror); err != nil {
3940
log.Fatal("Failed to map Mirror settings: %v", err)
4041
}

modules/setting/queue.go

+38-18
Original file line numberDiff line numberDiff line change
@@ -107,51 +107,71 @@ func NewQueueService() {
107107
Queue.SetName = sec.Key("SET_NAME").MustString("")
108108

109109
// Now handle the old issue_indexer configuration
110+
// FIXME: DEPRECATED to be removed in v1.18.0
110111
section := Cfg.Section("queue.issue_indexer")
111112
directlySet := toDirectlySetKeysMap(section)
112113
if !directlySet["TYPE"] && defaultType == "" {
113-
switch Indexer.IssueQueueType {
114-
case LevelQueueType:
114+
switch typ := Cfg.Section("indexer").Key("ISSUE_INDEXER_QUEUE_TYPE").MustString(""); typ {
115+
case "levelqueue":
115116
_, _ = section.NewKey("TYPE", "level")
116-
case ChannelQueueType:
117+
case "channel":
117118
_, _ = section.NewKey("TYPE", "persistable-channel")
118-
case RedisQueueType:
119+
case "redis":
119120
_, _ = section.NewKey("TYPE", "redis")
120121
case "":
121122
_, _ = section.NewKey("TYPE", "level")
122123
default:
123-
log.Fatal("Unsupported indexer queue type: %v",
124-
Indexer.IssueQueueType)
124+
log.Fatal("Unsupported indexer queue type: %v", typ)
125125
}
126126
}
127-
if !directlySet["LENGTH"] && Indexer.UpdateQueueLength != 0 {
128-
_, _ = section.NewKey("LENGTH", strconv.Itoa(Indexer.UpdateQueueLength))
127+
if !directlySet["LENGTH"] {
128+
length := Cfg.Section("indexer").Key("UPDATE_BUFFER_LEN").MustInt(0)
129+
if length != 0 {
130+
_, _ = section.NewKey("LENGTH", strconv.Itoa(length))
131+
}
129132
}
130-
if !directlySet["BATCH_LENGTH"] && Indexer.IssueQueueBatchNumber != 0 {
131-
_, _ = section.NewKey("BATCH_LENGTH", strconv.Itoa(Indexer.IssueQueueBatchNumber))
133+
if !directlySet["BATCH_LENGTH"] {
134+
fallback := Cfg.Section("indexer").Key("ISSUE_INDEXER_QUEUE_BATCH_NUMBER").MustInt(0)
135+
if fallback != 0 {
136+
_, _ = section.NewKey("BATCH_LENGTH", strconv.Itoa(fallback))
137+
}
132138
}
133-
if !directlySet["DATADIR"] && Indexer.IssueQueueDir != "" {
134-
_, _ = section.NewKey("DATADIR", Indexer.IssueQueueDir)
139+
if !directlySet["DATADIR"] {
140+
queueDir := filepath.ToSlash(Cfg.Section("indexer").Key("ISSUE_INDEXER_QUEUE_DIR").MustString(""))
141+
if queueDir != "" {
142+
_, _ = section.NewKey("DATADIR", queueDir)
143+
}
135144
}
136-
if !directlySet["CONN_STR"] && Indexer.IssueQueueConnStr != "" {
137-
_, _ = section.NewKey("CONN_STR", Indexer.IssueQueueConnStr)
145+
if !directlySet["CONN_STR"] {
146+
connStr := Cfg.Section("indexer").Key("ISSUE_INDEXER_QUEUE_CONN_STR").MustString("")
147+
if connStr != "" {
148+
_, _ = section.NewKey("CONN_STR", connStr)
149+
}
138150
}
139151

152+
// FIXME: DEPRECATED to be removed in v1.18.0
153+
// - will need to set default for [queue.*)] LENGTH appropriately though though
154+
140155
// Handle the old mailer configuration
141-
handleOldLengthConfiguration("mailer", Cfg.Section("mailer").Key("SEND_BUFFER_LEN").MustInt(100))
156+
handleOldLengthConfiguration("mailer", "mailer", "SEND_BUFFER_LEN", 100)
142157

143158
// Handle the old test pull requests configuration
144159
// Please note this will be a unique queue
145-
handleOldLengthConfiguration("pr_patch_checker", Cfg.Section("repository").Key("PULL_REQUEST_QUEUE_LENGTH").MustInt(1000))
160+
handleOldLengthConfiguration("pr_patch_checker", "repository", "PULL_REQUEST_QUEUE_LENGTH", 1000)
146161

147162
// Handle the old mirror queue configuration
148163
// Please note this will be a unique queue
149-
handleOldLengthConfiguration("mirror", Cfg.Section("repository").Key("MIRROR_QUEUE_LENGTH").MustInt(1000))
164+
handleOldLengthConfiguration("mirror", "repository", "MIRROR_QUEUE_LENGTH", 1000)
150165
}
151166

152167
// handleOldLengthConfiguration allows fallback to older configuration. `[queue.name]` `LENGTH` will override this configuration, but
153168
// if that is left unset then we should fallback to the older configuration. (Except where the new length woul be <=0)
154-
func handleOldLengthConfiguration(queueName string, value int) {
169+
func handleOldLengthConfiguration(queueName, oldSection, oldKey string, defaultValue int) {
170+
if Cfg.Section(oldSection).HasKey(oldKey) {
171+
log.Error("Deprecated fallback for %s queue length `[%s]` `%s` present. Use `[queue.%s]` `LENGTH`. This will be removed in v1.18.0", queueName, queueName, oldSection, oldKey)
172+
}
173+
value := Cfg.Section(oldSection).Key(oldKey).MustInt(defaultValue)
174+
155175
// Don't override with 0
156176
if value <= 0 {
157177
return

modules/setting/setting.go

+11
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ var (
387387
MaxTokenLength: math.MaxInt16,
388388
}
389389

390+
// FIXME: DEPRECATED to be removed in v1.18.0
390391
U2F = struct {
391392
AppID string
392393
}{}
@@ -563,6 +564,12 @@ func LoadForTest(extraConfigs ...string) {
563564
}
564565
}
565566

567+
func deprecatedSetting(oldSection, oldKey, newSection, newKey string) {
568+
if Cfg.Section(oldSection).HasKey(oldKey) {
569+
log.Error("Deprecated fallback `[%s]` `%s` present. Use `[%s]` `%s` instead. This fallback will be removed in v1.18.0", oldSection, oldKey, newSection, newKey)
570+
}
571+
}
572+
566573
// loadFromConf initializes configuration context.
567574
// NOTE: do not print any log except error.
568575
func loadFromConf(allowEmpty bool, extraConfig string) {
@@ -1022,6 +1029,10 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
10221029
UI.CustomEmojisMap[emoji] = ":" + emoji + ":"
10231030
}
10241031

1032+
// FIXME: DEPRECATED to be removed in v1.18.0
1033+
if Cfg.Section("U2F").HasKey("APP_ID") {
1034+
log.Error("Deprecated setting `[U2F]` `APP_ID` present. This fallback will be removed in v1.18.0")
1035+
}
10251036
sec = Cfg.Section("U2F")
10261037
U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimSuffix(AppURL, "/"))
10271038
}

modules/setting/task.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@
44

55
package setting
66

7+
// FIXME: DEPRECATED to be removed in v1.18.0
8+
// - will need to set default for [queue.task] LENGTH to 1000 though
79
func newTaskService() {
810
taskSec := Cfg.Section("task")
911
queueTaskSec := Cfg.Section("queue.task")
10-
switch taskSec.Key("QUEUE_TYPE").MustString(ChannelQueueType) {
11-
case ChannelQueueType:
12+
13+
deprecatedSetting("task", "QUEUE_TYPE", "queue.task", "TYPE")
14+
deprecatedSetting("task", "QUEUE_CONN_STR", "queue.task", "CONN_STR")
15+
deprecatedSetting("task", "QUEUE_LENGTH", "queue.task", "LENGTH")
16+
17+
switch taskSec.Key("QUEUE_TYPE").MustString("channel") {
18+
case "channel":
1219
queueTaskSec.Key("TYPE").MustString("persistable-channel")
1320
queueTaskSec.Key("CONN_STR").MustString(taskSec.Key("QUEUE_CONN_STR").MustString(""))
14-
case RedisQueueType:
21+
case "redis":
1522
queueTaskSec.Key("TYPE").MustString("redis")
1623
queueTaskSec.Key("CONN_STR").MustString(taskSec.Key("QUEUE_CONN_STR").MustString("addrs=127.0.0.1:6379 db=0"))
1724
}

routers/web/auth/webauthn.go

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func WebAuthnLoginAssertion(ctx *context.Context) {
6767
return
6868
}
6969

70+
// FIXME: DEPRECATED appid is deprecated and is planned to be removed in v1.18.0
7071
assertion, sessionData, err := wa.WebAuthn.BeginLogin((*wa.User)(user), webauthn.WithAssertionExtensions(protocol.AuthenticationExtensions{
7172
"appid": setting.U2F.AppID,
7273
}))

0 commit comments

Comments
 (0)