mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Config: refactor config file loaders (#577)
* Config: fix don't create empty dir when resolving path * Config: refactor config file loaders * add a layer of abstraction so that config can be loaded from non-files * use io.Reader / io.Writer abstraction to separate data operations from file operations * remove dryrun option from SaveConfig - now it always saves * rename read and save methods to mention file operations * log error when encryption prompt fails * as the user didn't make a choice, we'd prompt again next time the file is loaded * add file.Writer tests * skip permissions test for windows * defer creating the writer on save to the last moment * this avoids truncating file when there is error with password prompt * add a test * tests with StdIn cannot run in parallel
This commit is contained in:
@@ -104,7 +104,7 @@ func loadConfigWithSettings(settings *Settings, flagSet map[string]bool) (*confi
|
||||
log.Printf("Loading config file %s..\n", filePath)
|
||||
|
||||
conf := &config.Cfg
|
||||
err = conf.ReadConfig(filePath, settings.EnableDryRun)
|
||||
err = conf.ReadConfigFromFile(filePath, settings.EnableDryRun)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(config.ErrFailureOpeningConfig, filePath, err)
|
||||
}
|
||||
@@ -541,7 +541,7 @@ func (bot *Engine) Stop() {
|
||||
}
|
||||
|
||||
if !bot.Settings.EnableDryRun {
|
||||
err := bot.Config.SaveConfig(bot.Settings.ConfigFile, false)
|
||||
err := bot.Config.SaveConfigToFile(bot.Settings.ConfigFile)
|
||||
if err != nil {
|
||||
gctlog.Errorln(gctlog.Global, "Unable to save config.")
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user