feature: issue #38 - Config Directories

This commit is contained in:
jamesread 2022-03-23 16:17:45 +00:00
parent bb96072682
commit 3ad640aee0
1 changed files with 11 additions and 1 deletions

View File

@ -1,6 +1,8 @@
package main
import (
"flag"
log "github.com/sirupsen/logrus"
grpcapi "github.com/jamesread/OliveTin/internal/grpcapi"
@ -30,10 +32,18 @@ func init() {
log.SetLevel(log.DebugLevel) // Default to debug, to catch cfg issues
var configDir string;
flag.StringVar(&configDir, "configdir", ".", "Config directory path")
flag.Parse()
log.WithFields(log.Fields{
"value": configDir,
}).Debugf("Value of -configdir flag")
viper.AutomaticEnv()
viper.SetConfigName("config.yaml")
viper.SetConfigType("yaml")
viper.AddConfigPath(".")
viper.AddConfigPath(configDir)
viper.AddConfigPath("/config") // For containers.
viper.AddConfigPath("/etc/OliveTin/")