Began work on refactoring reading config values

This commit is contained in:
Torkel Ödegaard
2015-04-08 20:31:42 +02:00
parent 9c2040aa9b
commit a991cda233
28 changed files with 83 additions and 3661 deletions
+12 -9
View File
@@ -175,6 +175,17 @@ func loadEnvVariableOverrides() {
}
}
func evalutePathConfig(value, commandLineVal, def string) string {
if value == "" {
if commandLineVal != "" {
return commandLineVal
} else {
return def
}
}
return value
}
func NewConfigContext(args *CommandLineArgs) {
findConfigFiles(args.Config)
@@ -196,15 +207,7 @@ func NewConfigContext(args *CommandLineArgs) {
loadEnvVariableOverrides()
DataPath = Cfg.Section("").Key("data_path").String()
// if no data path in config, use command line, otherwise default to
// data folder relative to working dir
if DataPath == "" {
if args.DefaultDataPath != "" {
DataPath = args.DefaultDataPath
} else {
DataPath = filepath.Join(WorkPath, "data")
}
}
DataPath = evalutePathConfig(DataPath, args.DefaultDataPath, filepath.Join(WorkPath, "data"))
initLogging(args)