Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/config.go')
-rw-r--r--internal/config/config.go17
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"`
}