diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-06-02 17:27:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-02 17:27:30 +0800 |
commit | de4a21fcb4476772c69c36d086549e89ed4dcf6c (patch) | |
tree | a8952b92bc6382daffc34178f5d6cc32cfea2efd /contrib | |
parent | 7a5873335afb00dda5fa123fb023c88278e79deb (diff) | |
download | gitea-de4a21fcb4476772c69c36d086549e89ed4dcf6c.tar.gz gitea-de4a21fcb4476772c69c36d086549e89ed4dcf6c.zip |
Refactor INI package (first step) (#25024)
The INI package has many bugs and quirks, and in fact it is
unmaintained.
This PR is the first step for the INI package refactoring:
* Use Gitea's "config_provider" to provide INI access
* Deprecate the INI package by golangci.yml rule
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/environment-to-ini/environment-to-ini.go | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/contrib/environment-to-ini/environment-to-ini.go b/contrib/environment-to-ini/environment-to-ini.go index ae8535d891..3405d7d429 100644 --- a/contrib/environment-to-ini/environment-to-ini.go +++ b/contrib/environment-to-ini/environment-to-ini.go @@ -9,10 +9,8 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - "code.gitea.io/gitea/modules/util" "github.com/urfave/cli" - "gopkg.in/ini.v1" ) // EnvironmentPrefix environment variables prefixed with this represent ini values to write @@ -97,19 +95,10 @@ func runEnvironmentToIni(c *cli.Context) error { providedWorkPath := c.String("work-path") setting.SetCustomPathAndConf(providedCustom, providedConf, providedWorkPath) - cfg := ini.Empty() - confFileExists, err := util.IsFile(setting.CustomConf) + cfg, err := setting.NewConfigProviderFromFile(&setting.Options{CustomConf: setting.CustomConf, AllowEmpty: true}) if err != nil { - log.Fatal("Unable to check if %s is a file. Error: %v", setting.CustomConf, err) + log.Fatal("Failed to load custom conf '%s': %v", setting.CustomConf, err) } - if confFileExists { - if err := cfg.Append(setting.CustomConf); err != nil { - log.Fatal("Failed to load custom conf '%s': %v", setting.CustomConf, err) - } - } else { - log.Warn("Custom config '%s' not found, ignore this if you're running first time", setting.CustomConf) - } - cfg.NameMapper = ini.SnackCase prefixGitea := c.String("prefix") + "__" suffixFile := "__FILE" |