diff --git a/cmd/lasso/cmd/root.go b/cmd/lasso/cmd/root.go index a973674..ee7d1de 100644 --- a/cmd/lasso/cmd/root.go +++ b/cmd/lasso/cmd/root.go @@ -19,6 +19,7 @@ package cmd import ( "fmt" "net/http" + "strings" "github.com/rs/zerolog/log" "github.com/spf13/cobra" @@ -58,6 +59,7 @@ func initConfig() { viper.SetConfigName("lasso") } + viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) viper.SetEnvPrefix("lasso") viper.AutomaticEnv() // Read in environment variables that match diff --git a/cmd/lassoctl/cmd/root.go b/cmd/lassoctl/cmd/root.go index e60d2e4..bb2ba52 100644 --- a/cmd/lassoctl/cmd/root.go +++ b/cmd/lassoctl/cmd/root.go @@ -19,7 +19,7 @@ package cmd import ( "net" "net/http" - "os" + "strings" "github.com/abiosoft/ishell" "github.com/mitchellh/mapstructure" @@ -57,17 +57,12 @@ func initConfig() { // Use config file from the flag. viper.SetConfigFile(cfgFile) } else { - // Find home directory. - home, err := os.UserHomeDir() - cobra.CheckErr(err) - - // Search config in home directory with name ".lassoctl" (without extension). - viper.AddConfigPath(".") - viper.AddConfigPath(home) - viper.SetConfigType("toml") + viper.SetConfigType("/etc") viper.SetConfigName("lassoctl") } + viper.SetEnvPrefix("lassoctl") + viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) viper.AutomaticEnv() // read in environment variables that match // If a config file is found, read it in.