Config overwrite bugfix (#363)

* Fix bug where on parsing an alternate new config it will overwrite main config.json in gct dir

* Stop movement of config.json file from root dir when a new config is parsed in

* Stop overiding config.json at gct dir with new config.json from root directory

* RM LN :D

* Fix bug where promptforconfig in config_encryption.go overwrites default config
Ensure periphery command packages do not interact or save over configuration
Ensure tests to not save over or change current testdata/config
This commit is contained in:
Ryan O'Hara-Reid
2019-09-27 16:03:41 +10:00
committed by Adrian Gallagher
parent 6bdbe236c0
commit e2d57540a6
55 changed files with 408 additions and 173 deletions

View File

@@ -112,7 +112,8 @@ func main() {
}
conf := config.GetConfig()
err = conf.LoadConfig(configFile)
err = conf.LoadConfig(configFile, true)
if err != nil {
fmt.Println(err)
os.Exit(1)

View File

@@ -99,7 +99,7 @@ func main() {
}
configTestFile := config.GetConfig()
err = configTestFile.LoadConfig(exchangeConfigPath)
err = configTestFile.LoadConfig(exchangeConfigPath, true)
if err != nil {
log.Fatal("GoCryptoTrader: Exchange templating configuration retrieval error ", err)
}
@@ -129,7 +129,7 @@ func main() {
configTestFile.Exchanges = append(configTestFile.Exchanges, newExchConfig)
// TODO sorting function so exchanges are in alphabetical order - low priority
err = configTestFile.SaveConfig(exchangeJSON)
err = configTestFile.SaveConfig(exchangeJSON, false)
if err != nil {
log.Fatal("GoCryptoTrader: Exchange templating configuration error - cannot save")
}

View File

@@ -62,7 +62,7 @@ func main() {
// Otherwise default to loading the config file and generating OTP codes from it
var cfg config.Config
err = cfg.LoadConfig(cfgFile)
err = cfg.LoadConfig(cfgFile, true)
if err != nil {
log.Fatal(err)
}

View File

@@ -77,7 +77,7 @@ func main() {
log.Println("GoCryptoTrader: portfolio tool.")
var cfg config.Config
err = cfg.LoadConfig(inFile)
err = cfg.LoadConfig(inFile, true)
if err != nil {
log.Println(err)
os.Exit(1)

View File

@@ -76,7 +76,7 @@ func SendWebsocketEvent(event string, reqData interface{}, result *WebsocketEven
func main() {
cfg := config.GetConfig()
err := cfg.LoadConfig(config.ConfigFile)
err := cfg.LoadConfig(config.ConfigFile, true)
if err != nil {
log.Fatalf("Failed to load config file: %s", err)
}