diff --git a/modules/indexer/issues/indexer.go b/modules/indexer/issues/indexer.go index 4db5091762..8530210628 100644 --- a/modules/indexer/issues/indexer.go +++ b/modules/indexer/issues/indexer.go @@ -110,7 +110,7 @@ func InitIssueIndexer(syncReindex bool) { return } - iData := make([]*IndexerData, 0, setting.Indexer.IssueQueueBatchNumber) + iData := make([]*IndexerData, 0, len(data)) for _, datum := range data { indexerData, ok := datum.(*IndexerData) if !ok { diff --git a/modules/indexer/issues/indexer_test.go b/modules/indexer/issues/indexer_test.go index 866e3cc7c9..ba35e37fd8 100644 --- a/modules/indexer/issues/indexer_test.go +++ b/modules/indexer/issues/indexer_test.go @@ -34,12 +34,12 @@ func TestBleveSearchIssues(t *testing.T) { assert.Fail(t, "Unable to create temporary directory: %v", err) return } - oldQueueDir := setting.Indexer.IssueQueueDir + + setting.Cfg.Section("queue.issue_indexer").Key("DATADIR").MustString(path.Join(tmpIndexerDir, "issues.queue")) + oldIssuePath := setting.Indexer.IssuePath - setting.Indexer.IssueQueueDir = path.Join(tmpIndexerDir, "issues.queue") setting.Indexer.IssuePath = path.Join(tmpIndexerDir, "issues.queue") defer func() { - setting.Indexer.IssueQueueDir = oldQueueDir setting.Indexer.IssuePath = oldIssuePath util.RemoveAll(tmpIndexerDir) }() diff --git a/modules/setting/indexer.go b/modules/setting/indexer.go index 2e9d8b2883..f103a7464b 100644 --- a/modules/setting/indexer.go +++ b/modules/setting/indexer.go @@ -14,32 +14,20 @@ import ( "github.com/gobwas/glob" ) -// enumerates all the indexer queue types -const ( - LevelQueueType = "levelqueue" - ChannelQueueType = "channel" - RedisQueueType = "redis" -) - var ( // Indexer settings Indexer = struct { - IssueType string - IssuePath string - IssueConnStr string - IssueIndexerName string - IssueQueueType string // DEPRECATED - replaced by queue.issue_indexer - IssueQueueDir string // DEPRECATED - replaced by queue.issue_indexer - IssueQueueConnStr string // DEPRECATED - replaced by queue.issue_indexer - IssueQueueBatchNumber int // DEPRECATED - replaced by queue.issue_indexer - StartupTimeout time.Duration + IssueType string + IssuePath string + IssueConnStr string + IssueIndexerName string + StartupTimeout time.Duration RepoIndexerEnabled bool RepoType string RepoPath string RepoConnStr string RepoIndexerName string - UpdateQueueLength int // DEPRECATED - replaced by queue.issue_indexer MaxIndexerFileSize int64 IncludePatterns []glob.Glob ExcludePatterns []glob.Glob @@ -49,7 +37,6 @@ var ( IssuePath: "indexers/issues.bleve", IssueConnStr: "", IssueIndexerName: "gitea_issues", - IssueQueueType: LevelQueueType, RepoIndexerEnabled: false, RepoType: "bleve", @@ -72,11 +59,12 @@ func newIndexerService() { Indexer.IssueIndexerName = sec.Key("ISSUE_INDEXER_NAME").MustString(Indexer.IssueIndexerName) // The following settings are deprecated and can be overridden by settings in [queue] or [queue.issue_indexer] - Indexer.IssueQueueType = sec.Key("ISSUE_INDEXER_QUEUE_TYPE").MustString("") - Indexer.IssueQueueDir = filepath.ToSlash(sec.Key("ISSUE_INDEXER_QUEUE_DIR").MustString("")) - Indexer.IssueQueueConnStr = sec.Key("ISSUE_INDEXER_QUEUE_CONN_STR").MustString("") - Indexer.IssueQueueBatchNumber = sec.Key("ISSUE_INDEXER_QUEUE_BATCH_NUMBER").MustInt(0) - Indexer.UpdateQueueLength = sec.Key("UPDATE_BUFFER_LEN").MustInt(0) + // FIXME: DEPRECATED to be removed in v1.18.0 + deprecatedSetting("indexer", "ISSUE_INDEXER_QUEUE_TYPE", "queue.issue_indexer", "TYPE") + deprecatedSetting("indexer", "ISSUE_INDEXER_QUEUE_DIR", "queue.issue_indexer", "DATADIR") + deprecatedSetting("indexer", "ISSUE_INDEXER_QUEUE_CONN_STR", "queue.issue_indexer", "CONN_STR") + deprecatedSetting("indexer", "ISSUE_INDEXER_QUEUE_BATCH_NUMBER", "queue.issue_indexer", "BATCH_LENGTH") + deprecatedSetting("indexer", "UPDATE_BUFFER_LEN", "queue.issue_indexer", "LENGTH") Indexer.RepoIndexerEnabled = sec.Key("REPO_INDEXER_ENABLED").MustBool(false) Indexer.RepoType = sec.Key("REPO_INDEXER_TYPE").MustString("bleve") diff --git a/modules/setting/lfs.go b/modules/setting/lfs.go index a4bbd3c3ff..7065ce6383 100644 --- a/modules/setting/lfs.go +++ b/modules/setting/lfs.go @@ -36,6 +36,8 @@ func newLFSService() { storageType := lfsSec.Key("STORAGE_TYPE").MustString("") // Specifically default PATH to LFS_CONTENT_PATH + //FIXME: DEPRECATED to be removed in v1.18.0 + deprecatedSetting("server", "LFS_CONTENT_PATH", "lfs", "PATH") lfsSec.Key("PATH").MustString( sec.Key("LFS_CONTENT_PATH").String()) diff --git a/modules/setting/mailer.go b/modules/setting/mailer.go index d7713f3b80..5da520171e 100644 --- a/modules/setting/mailer.go +++ b/modules/setting/mailer.go @@ -79,13 +79,15 @@ func newMailService() { MailService.From = sec.Key("FROM").MustString(MailService.User) MailService.EnvelopeFrom = sec.Key("ENVELOPE_FROM").MustString("") + // FIXME: DEPRECATED to be removed in v1.18.0 + deprecatedSetting("mailer", "ENABLE_HTML_ALTERNATIVE", "mailer", "SEND_AS_PLAIN_TEXT") if sec.HasKey("ENABLE_HTML_ALTERNATIVE") { - log.Warn("ENABLE_HTML_ALTERNATIVE is deprecated, use SEND_AS_PLAIN_TEXT") MailService.SendAsPlainText = !sec.Key("ENABLE_HTML_ALTERNATIVE").MustBool(false) } + // FIXME: DEPRECATED to be removed in v1.18.0 + deprecatedSetting("mailer", "USE_SENDMAIL", "mailer", "MAILER_TYPE") if sec.HasKey("USE_SENDMAIL") { - log.Warn("USE_SENDMAIL is deprecated, use MAILER_TYPE=sendmail") if MailService.MailerType == "" && sec.Key("USE_SENDMAIL").MustBool(false) { MailService.MailerType = "sendmail" } diff --git a/modules/setting/mirror.go b/modules/setting/mirror.go index b0d5b2a4dc..e49393e39c 100644 --- a/modules/setting/mirror.go +++ b/modules/setting/mirror.go @@ -30,11 +30,12 @@ var ( func newMirror() { // Handle old configuration through `[repository]` `DISABLE_MIRRORS` // - please note this was badly named and only disabled the creation of new pull mirrors + // FIXME: DEPRECATED to be removed in v1.18.0 + deprecatedSetting("repository", "DISABLE_MIRRORS", "mirror", "ENABLED") if Cfg.Section("repository").Key("DISABLE_MIRRORS").MustBool(false) { - log.Warn("Deprecated DISABLE_MIRRORS config is used, please change your config and use the options within the [mirror] section") - // TODO: enable on v1.17.0: log.Error("Deprecated fallback used, will be removed in v1.18.0") Mirror.DisableNewPull = true } + if err := Cfg.Section("mirror").MapTo(&Mirror); err != nil { log.Fatal("Failed to map Mirror settings: %v", err) } diff --git a/modules/setting/queue.go b/modules/setting/queue.go index 56a036aeef..cb86cbdfe0 100644 --- a/modules/setting/queue.go +++ b/modules/setting/queue.go @@ -107,51 +107,71 @@ func NewQueueService() { Queue.SetName = sec.Key("SET_NAME").MustString("") // Now handle the old issue_indexer configuration + // FIXME: DEPRECATED to be removed in v1.18.0 section := Cfg.Section("queue.issue_indexer") directlySet := toDirectlySetKeysMap(section) if !directlySet["TYPE"] && defaultType == "" { - switch Indexer.IssueQueueType { - case LevelQueueType: + switch typ := Cfg.Section("indexer").Key("ISSUE_INDEXER_QUEUE_TYPE").MustString(""); typ { + case "levelqueue": _, _ = section.NewKey("TYPE", "level") - case ChannelQueueType: + case "channel": _, _ = section.NewKey("TYPE", "persistable-channel") - case RedisQueueType: + case "redis": _, _ = section.NewKey("TYPE", "redis") case "": _, _ = section.NewKey("TYPE", "level") default: - log.Fatal("Unsupported indexer queue type: %v", - Indexer.IssueQueueType) + log.Fatal("Unsupported indexer queue type: %v", typ) } } - if !directlySet["LENGTH"] && Indexer.UpdateQueueLength != 0 { - _, _ = section.NewKey("LENGTH", strconv.Itoa(Indexer.UpdateQueueLength)) + if !directlySet["LENGTH"] { + length := Cfg.Section("indexer").Key("UPDATE_BUFFER_LEN").MustInt(0) + if length != 0 { + _, _ = section.NewKey("LENGTH", strconv.Itoa(length)) + } } - if !directlySet["BATCH_LENGTH"] && Indexer.IssueQueueBatchNumber != 0 { - _, _ = section.NewKey("BATCH_LENGTH", strconv.Itoa(Indexer.IssueQueueBatchNumber)) + if !directlySet["BATCH_LENGTH"] { + fallback := Cfg.Section("indexer").Key("ISSUE_INDEXER_QUEUE_BATCH_NUMBER").MustInt(0) + if fallback != 0 { + _, _ = section.NewKey("BATCH_LENGTH", strconv.Itoa(fallback)) + } } - if !directlySet["DATADIR"] && Indexer.IssueQueueDir != "" { - _, _ = section.NewKey("DATADIR", Indexer.IssueQueueDir) + if !directlySet["DATADIR"] { + queueDir := filepath.ToSlash(Cfg.Section("indexer").Key("ISSUE_INDEXER_QUEUE_DIR").MustString("")) + if queueDir != "" { + _, _ = section.NewKey("DATADIR", queueDir) + } } - if !directlySet["CONN_STR"] && Indexer.IssueQueueConnStr != "" { - _, _ = section.NewKey("CONN_STR", Indexer.IssueQueueConnStr) + if !directlySet["CONN_STR"] { + connStr := Cfg.Section("indexer").Key("ISSUE_INDEXER_QUEUE_CONN_STR").MustString("") + if connStr != "" { + _, _ = section.NewKey("CONN_STR", connStr) + } } + // FIXME: DEPRECATED to be removed in v1.18.0 + // - will need to set default for [queue.*)] LENGTH appropriately though though + // Handle the old mailer configuration - handleOldLengthConfiguration("mailer", Cfg.Section("mailer").Key("SEND_BUFFER_LEN").MustInt(100)) + handleOldLengthConfiguration("mailer", "mailer", "SEND_BUFFER_LEN", 100) // Handle the old test pull requests configuration // Please note this will be a unique queue - handleOldLengthConfiguration("pr_patch_checker", Cfg.Section("repository").Key("PULL_REQUEST_QUEUE_LENGTH").MustInt(1000)) + handleOldLengthConfiguration("pr_patch_checker", "repository", "PULL_REQUEST_QUEUE_LENGTH", 1000) // Handle the old mirror queue configuration // Please note this will be a unique queue - handleOldLengthConfiguration("mirror", Cfg.Section("repository").Key("MIRROR_QUEUE_LENGTH").MustInt(1000)) + handleOldLengthConfiguration("mirror", "repository", "MIRROR_QUEUE_LENGTH", 1000) } // handleOldLengthConfiguration allows fallback to older configuration. `[queue.name]` `LENGTH` will override this configuration, but // if that is left unset then we should fallback to the older configuration. (Except where the new length woul be <=0) -func handleOldLengthConfiguration(queueName string, value int) { +func handleOldLengthConfiguration(queueName, oldSection, oldKey string, defaultValue int) { + if Cfg.Section(oldSection).HasKey(oldKey) { + 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) + } + value := Cfg.Section(oldSection).Key(oldKey).MustInt(defaultValue) + // Don't override with 0 if value <= 0 { return diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 26eeda525f..3c8e009daa 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -387,6 +387,7 @@ var ( MaxTokenLength: math.MaxInt16, } + // FIXME: DEPRECATED to be removed in v1.18.0 U2F = struct { AppID string }{} @@ -563,6 +564,12 @@ func LoadForTest(extraConfigs ...string) { } } +func deprecatedSetting(oldSection, oldKey, newSection, newKey string) { + if Cfg.Section(oldSection).HasKey(oldKey) { + log.Error("Deprecated fallback `[%s]` `%s` present. Use `[%s]` `%s` instead. This fallback will be removed in v1.18.0", oldSection, oldKey, newSection, newKey) + } +} + // loadFromConf initializes configuration context. // NOTE: do not print any log except error. func loadFromConf(allowEmpty bool, extraConfig string) { @@ -1022,6 +1029,10 @@ func loadFromConf(allowEmpty bool, extraConfig string) { UI.CustomEmojisMap[emoji] = ":" + emoji + ":" } + // FIXME: DEPRECATED to be removed in v1.18.0 + if Cfg.Section("U2F").HasKey("APP_ID") { + log.Error("Deprecated setting `[U2F]` `APP_ID` present. This fallback will be removed in v1.18.0") + } sec = Cfg.Section("U2F") U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimSuffix(AppURL, "/")) } diff --git a/modules/setting/task.go b/modules/setting/task.go index d9329dbb76..c39d441108 100644 --- a/modules/setting/task.go +++ b/modules/setting/task.go @@ -4,14 +4,21 @@ package setting +// FIXME: DEPRECATED to be removed in v1.18.0 +// - will need to set default for [queue.task] LENGTH to 1000 though func newTaskService() { taskSec := Cfg.Section("task") queueTaskSec := Cfg.Section("queue.task") - switch taskSec.Key("QUEUE_TYPE").MustString(ChannelQueueType) { - case ChannelQueueType: + + deprecatedSetting("task", "QUEUE_TYPE", "queue.task", "TYPE") + deprecatedSetting("task", "QUEUE_CONN_STR", "queue.task", "CONN_STR") + deprecatedSetting("task", "QUEUE_LENGTH", "queue.task", "LENGTH") + + switch taskSec.Key("QUEUE_TYPE").MustString("channel") { + case "channel": queueTaskSec.Key("TYPE").MustString("persistable-channel") queueTaskSec.Key("CONN_STR").MustString(taskSec.Key("QUEUE_CONN_STR").MustString("")) - case RedisQueueType: + case "redis": queueTaskSec.Key("TYPE").MustString("redis") queueTaskSec.Key("CONN_STR").MustString(taskSec.Key("QUEUE_CONN_STR").MustString("addrs=127.0.0.1:6379 db=0")) } diff --git a/routers/web/auth/webauthn.go b/routers/web/auth/webauthn.go index b9e8de2ac0..77b1bee18a 100644 --- a/routers/web/auth/webauthn.go +++ b/routers/web/auth/webauthn.go @@ -67,6 +67,7 @@ func WebAuthnLoginAssertion(ctx *context.Context) { return } + // FIXME: DEPRECATED appid is deprecated and is planned to be removed in v1.18.0 assertion, sessionData, err := wa.WebAuthn.BeginLogin((*wa.User)(user), webauthn.WithAssertionExtensions(protocol.AuthenticationExtensions{ "appid": setting.U2F.AppID, }))