diff options
author | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-03-30 05:35:25 +0300 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-03-30 05:35:25 +0300 |
commit | b74ed7eec6e40ce5355174ec5741a6d93ea1f9f6 (patch) | |
tree | b8f03f04d9275dda7e985ed866174847079c189a | |
parent | ea48d3433a8ee1e53a6a3e790602923157a2ad50 (diff) |
Actually store the config in memoryplumbing/shard-config
-rw-r--r-- | internal/config/config.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index f3e2a1dcf..2cdc8aa09 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -8,7 +8,7 @@ import ( ) var ( - Config *config + Config config configFile string ) @@ -22,19 +22,28 @@ func init() { configFile := viper.GetString("config") + if len(configFile) == 0 { + panic(fmt.Errorf("fatal: no config file given")) + } + viper.SetConfigFile(configFile) err := viper.ReadInConfig() if err != nil { panic(fmt.Errorf("fatal: read config file: %q", configFile)) } + + err = viper.Unmarshal(&Config) + if err != nil { + panic(fmt.Errorf("fatal: unable to decode config: %q: %v", configFile, err)) + } } type Storage struct { - Name string `toml:"name"` - Path string `toml:"path"` + Name string + Path string } type config struct { - Storages []Storage `toml:"storage"` + Storages []Storage `mapstructure:"storage"` } |