mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-24 11:58:17 +01:00
Enable deprecation error for v1.17.0 (#18341)
Co-authored-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
16d378fefc
commit
1d98d205f5
@ -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 {
|
||||
|
@ -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)
|
||||
}()
|
||||
|
@ -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")
|
||||
|
@ -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())
|
||||
|
||||
|
@ -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"
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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, "/"))
|
||||
}
|
||||
|
@ -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"))
|
||||
}
|
||||
|
@ -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,
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user