-
-
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
Add contrib/ini-to-shell #32669
base: main
Are you sure you want to change the base?
Add contrib/ini-to-shell #32669
Conversation
Signed-off-by: justusbunsi <[email protected]>
Signed-off-by: justusbunsi <[email protected]>
Signed-off-by: justusbunsi <[email protected]>
Test error seems unrelated |
golog.SetOutput(os.Stdout) | ||
golog.SetFlags(golog.Flags() &^ (golog.Ldate | golog.Ltime)) | ||
golog.Println(section.Key(kName).Value()) |
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.
I do not think it should use log
module, it should just print to stdout as-is
setting.InitWorkPathAndCfgProvider(os.Getenv, setting.ArgWorkPathAndCustomConf{ | ||
WorkPath: c.String("work-path"), | ||
CustomPath: c.String("custom-path"), | ||
CustomConf: c.String("config"), | ||
}) |
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.
Necessary?
I think we only need to pass the "config file" to the program, without InitWorkPathAndCfgProvider
, and just NewConfigProviderFromFile
I do not quite understand the usage. Could you provide more details about how to "extract all values that must be persistent" and "restore default"? The ini config system is quite tricky, if something wrong, it wouldn't be easy to fix. |
The problem is that some settings are passend by env to Gitea and these settings then are written to the ini file. If you remove the setting from the env the user expects to get the default value again. But that's not the case because the old value was written to the ini. To get rid of it they would like to create a new ini on startup but recreating the ini looses values like |
Then the current It already supports using an existing ini to create a new ini, now, we only need to make it support "only use specialized keys from existing ini":
|
@KN4CK3R Thank you for the summary. 👍 @wxiaoguang Extending the environment-to-ini seems like a better approach. I wasn't aware that it can copy/migrate. I'll try implementing it. |
There is no IIRC global keys are written as |
Maybe there could be another approach (I am not sure which one is better) If we'd like to "revert a key to default", maybe we could pass a special env value to it, eg: Actually for most cases, empty string should be enough, empty string in ini means default: |
Yep, I'll try to implement this flag. My question regarding RUN_MODE was to discuss how such global keys could be passed to the new flag.
That's not really possible. You cannot know dropped settings because there is no env variable anymore. The |
Description of the change
This adds a new binary for extracting settings from an existing
app.ini
.Benefits
Instead of
grep
-ing the file via shell scripts, this binary uses the Gitea internals for reading theapp.ini
.Possible drawbacks
None
Applicable issues
Helps addressing https://gitea.com/gitea/helm-chart/issues/356.
Signed-off-by: justusbunsi [email protected]