diff options
Diffstat (limited to 'modules/setting/setting.go')
-rw-r--r-- | modules/setting/setting.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 8b67a45175..83904080de 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -548,17 +548,17 @@ func SetCustomPathAndConf(providedCustom, providedConf, providedWorkPath string) // LoadFromExisting initializes setting options from an existing config file (app.ini) func LoadFromExisting() { - loadFromConf(false) + loadFromConf(false, "") } // LoadAllowEmpty initializes setting options, it's also fine that if the config file (app.ini) doesn't exist func LoadAllowEmpty() { - loadFromConf(true) + loadFromConf(true, "") } // LoadForTest initializes setting options for tests -func LoadForTest() { - loadFromConf(true) +func LoadForTest(extraConfigs ...string) { + loadFromConf(true, strings.Join(extraConfigs, "\n")) if err := PrepareAppDataPath(); err != nil { log.Fatal("Can not prepare APP_DATA_PATH: %v", err) } @@ -566,7 +566,7 @@ func LoadForTest() { // loadFromConf initializes configuration context. // NOTE: do not print any log except error. -func loadFromConf(allowEmpty bool) { +func loadFromConf(allowEmpty bool, extraConfig string) { Cfg = ini.Empty() if WritePIDFile && len(PIDFile) > 0 { @@ -585,6 +585,12 @@ func loadFromConf(allowEmpty bool) { log.Fatal("Unable to find configuration file: %q.\nEnsure you are running in the correct environment or set the correct configuration file with -c.", CustomConf) } // else: no config file, a config file might be created at CustomConf later (might not) + if extraConfig != "" { + if err = Cfg.Append([]byte(extraConfig)); err != nil { + log.Fatal("Unable to append more config: %v", err) + } + } + Cfg.NameMapper = ini.SnackCase homeDir, err := com.HomeDir() |