Fix viper configurations
This commit is contained in:
parent
0645bc876c
commit
593c56d91a
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user