-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notify about outdated settings #23203
Changes from all commits
d07784e
93bbad1
008f77d
aeb965d
c45ab0c
7f5503b
f3ddbd1
61e8af2
9f24391
b25df8b
78dc2d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package base | ||
|
||
import ( | ||
"code.gitea.io/gitea/modules/log" | ||
|
||
ini "gopkg.in/ini.v1" | ||
) | ||
|
||
// ConfigProvider represents a config provider | ||
type ConfigProvider interface { | ||
Section(section string) *ini.Section | ||
NewSection(name string) (*ini.Section, error) | ||
GetSection(name string) (*ini.Section, error) | ||
HasSection(name string) bool | ||
} | ||
|
||
// a file is an implementation ConfigProvider and other implementations are possible, i.e. from docker, k8s, … | ||
var _ ConfigProvider = &ini.File{} | ||
|
||
func MustMapSetting(rootCfg ConfigProvider, sectionName string, setting interface{}) { | ||
if err := rootCfg.Section(sectionName).MapTo(setting); err != nil { | ||
log.Fatal("Failed to map %s settings: %v", sectionName, err) | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package history | ||
|
||
import "code.gitea.io/gitea/modules/log" | ||
|
||
// This file is the only file that should be changed frequently in this package | ||
|
||
var currentGiteaVersion = getVersion("1.19") | ||
|
||
// Adds all previously removed settings | ||
// It should declare all breaking configuration changes in chronological order to ensure a monotone increasing error log | ||
func init() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So these information will be displayed before setting.Init ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, that's one of the reasons it is in its own package. (The other is a clear separation of what belongs to what)
No, it is called as soon as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think we should make the |
||
log.Trace("Start checking settings for if they are outdated") | ||
MoveIniSettingInSection("1.6", "api", "ENABLE_SWAGGER_ENDPOINT", "ENABLE_SWAGGER") | ||
|
||
PurgeIniSettings("1.9", "log.database", "LEVEL", "DRIVER", "CONN") | ||
|
||
MoveIniSetting("1.12", "markup.sanitizer", "ELEMENT", "markup.sanitizer.1", "ELEMENT") | ||
MoveIniSetting("1.12", "markup.sanitizer", "ALLOW_ATTR", "markup.sanitizer.1", "ALLOW_ATTR") | ||
MoveIniSetting("1.12", "markup.sanitizer", "REGEXP", "markup.sanitizer.1", "REGEXP") | ||
|
||
PurgeIniSettings("1.14", "log", "MACARON", "REDIRECT_MACARON_LOG") | ||
|
||
MoveIniSetting("1.15", "indexer", "ISSUE_INDEXER_QUEUE_TYPE", "queue.issue_indexer", "TYPE") | ||
MoveIniSetting("1.15", "indexer", "ISSUE_INDEXER_QUEUE_DIR", "queue.issue_indexer", "DATADIR") | ||
MoveIniSetting("1.15", "indexer", "ISSUE_INDEXER_QUEUE_CONN_STR", "queue.issue_indexer", "CONN_STR") | ||
MoveIniSetting("1.15", "indexer", "ISSUE_INDEXER_QUEUE_BATCH_NUMBER", "queue.issue_indexer", "BATCH_LENGTH") | ||
MoveIniSetting("1.15", "indexer", "UPDATE_BUFFER_LEN", "queue.issue_indexer", "LENGTH") | ||
|
||
MoveIniSettingInSection("1.17", "cron.archive_cleanup", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.update_mirrors", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.repo_health_check", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.check_repo_stats", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.update_migration_poster_id", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.sync_external_users", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.deleted_branches_cleanup", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.delete_inactive_accounts", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.delete_repo_archives", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.git_gc_repos", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.resync_all_sshkeys", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.resync_all_hooks", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.reinit_missing_repos", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.delete_missing_repos", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.delete_generated_repository_avatars", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
MoveIniSettingInSection("1.17", "cron.delete_old_actions", "NO_SUCCESS_NOTICE", "NOTIFY_ON_SUCCESS") | ||
|
||
PurgeIniSettings("1.18", "U2F", "APP_ID") | ||
MoveIniSettingsToDB("1.18", "picture", "ENABLE_FEDERATED_AVATAR", "DISABLE_GRAVATAR") | ||
MoveIniSettingInSection("1.18", "mailer", "HOST", "SMTP_ADDR") | ||
MoveIniSettingInSection("1.18", "mailer", "MAILER_TYPE", "PROTOCOL") | ||
MoveIniSettingInSection("1.18", "mailer", "IS_TLS_ENABLED", "PROTOCOL") | ||
MoveIniSettingInSection("1.18", "mailer", "DISABLE_HELO", "ENABLE_HELO") | ||
MoveIniSettingInSection("1.18", "mailer", "SKIP_VERIFY", "FORCE_TRUST_SERVER_CERT") | ||
MoveIniSettingInSection("1.18", "mailer", "USE_CERTIFICATE", "USE_CLIENT_CERT") | ||
MoveIniSettingInSection("1.18", "mailer", "CERT_FILE", "CLIENT_CERT_FILE") | ||
MoveIniSettingInSection("1.18", "mailer", "KEY_FILE", "CLIENT_KEY_FILE") | ||
MoveIniSettingInSection("1.18", "server", "ENABLE_LETSENCRYPT", "ENABLE_ACME") | ||
MoveIniSettingInSection("1.18", "server", "LETSENCRYPT_ACCEPTTOS", "ACME_ACCEPTTOS") | ||
MoveIniSettingInSection("1.18", "server", "LETSENCRYPT_DIRECTORY", "ACME_DIRECTORY") | ||
MoveIniSettingInSection("1.18", "server", "LETSENCRYPT_EMAIL", "ACME_EMAIL") | ||
MoveIniSetting("1.18", "server", "LFS_CONTENT_PATH", "lfs", "PATH") | ||
MoveIniSetting("1.18", "task", "QUEUE_TYPE", "queue.task", "TYPE") | ||
MoveIniSetting("1.18", "task", "QUEUE_CONN_STR", "queue.task", "CONN_STR") | ||
MoveIniSetting("1.18", "task", "QUEUE_LENGTH", "queue.task", "LENGTH") | ||
MoveIniSetting("1.18", "repository", "DISABLE_MIRRORS", "mirror", "ENABLED") | ||
|
||
PurgeIniSettings("1.19", "ui", "ONLY_SHOW_RELEVANT_REPOS") | ||
|
||
log.Trace("Finish checking settings for if they are outdated") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I don't think it's a good idea to ask maintainers to remember this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my mind, maybe:
git
to describe the base tag to get the working version?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please elaborate on how I get the information on what our current version is?
If I know how to do it, I can implement it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git describe
)git describe
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From #26094
The version is currently set in
main
gitea/main.go
Line 28 in 6aa30af
gitea/Makefile
Line 108 in 6aa30af
To use it elsewhere you'll need to move it to a non-main package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is especially that it isn't in the main package, and my attempts to convert it to
modules.setting.history.currentGiteaVersion
were all fruitless endeavors thus far.That's why this PR has moved to the back of my TODO list as I haven't found out yet what to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-X code.gitea.io/gitea/modules/setting/history.currentGiteaVersion=$(GITEA_VERSION)
should do the trick, although I'd recommend exporting the variable so we can use the same one in both places.