diff options
author | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-03-30 05:15:32 +0300 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-03-30 05:15:32 +0300 |
commit | d87a095a89c9159bef2a77084592672cd0ff67b8 (patch) | |
tree | b28d367e04751d2ed0d1aaf4c94691ee1acb3abc | |
parent | 00589ee91f31143df8eacf51d9fa20e5b7fb18f1 (diff) |
Initial config for sharding
-rw-r--r-- | cmd/gitaly/main.go | 1 | ||||
-rw-r--r-- | internal/config/config.go | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/cmd/gitaly/main.go b/cmd/gitaly/main.go index f24336b39..884ad564b 100644 --- a/cmd/gitaly/main.go +++ b/cmd/gitaly/main.go @@ -6,6 +6,7 @@ import ( "net/http" "os" + _ "gitlab.com/gitlab-org/gitaly/internal/config" "gitlab.com/gitlab-org/gitaly/internal/service" "gitlab.com/gitlab-org/gitaly/internal/service/middleware/panichandler" diff --git a/internal/config/config.go b/internal/config/config.go new file mode 100644 index 000000000..f3e2a1dcf --- /dev/null +++ b/internal/config/config.go @@ -0,0 +1,40 @@ +package config + +import ( + "fmt" + + flag "github.com/spf13/pflag" + "github.com/spf13/viper" +) + +var ( + Config *config + configFile string +) + +func init() { + flag.String("config", "", "Configfile to load") + flag.Parse() + + viper.SetEnvPrefix("gitaly") // Will be upper-cased by default + viper.BindEnv("config") + viper.BindPFlag("config", flag.Lookup("config")) + + configFile := viper.GetString("config") + + viper.SetConfigFile(configFile) + + err := viper.ReadInConfig() + if err != nil { + panic(fmt.Errorf("fatal: read config file: %q", configFile)) + } +} + +type Storage struct { + Name string `toml:"name"` + Path string `toml:"path"` +} + +type config struct { + Storages []Storage `toml:"storage"` +} |