diff --git a/cmd/root.go b/cmd/root.go index 236c501e9215c131af2953d6caadd3e6f0843807..4ee3a3b26f86f4516e6dfa707ce7a8983f2baa17 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -33,12 +33,10 @@ package cmd import ( "code.fbi.h-da.de/cocsn/gosdn/cli" "fmt" - "os" "github.com/spf13/cobra" + "os" - homedir "github.com/mitchellh/go-homedir" "github.com/spf13/viper" - ) @@ -76,7 +74,7 @@ func init() { // Cobra supports persistent flags, which, if defined here, // will be global for your application. - rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.gosdn.yaml)") + rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ./configs/gosdn.toml)") // Cobra also supports local flags, which will only run @@ -91,16 +89,8 @@ func initConfig() { // Use config file from the flag. viper.SetConfigFile(cfgFile) } else { - // Find home directory. - home, err := homedir.Dir() - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - // Search config in home directory with name ".gosdn" (without extension). - viper.AddConfigPath(home) - viper.SetConfigName(".gosdn") + viper.AddConfigPath("./configs") + viper.SetConfigName("gosdn") } viper.AutomaticEnv() // read in environment variables that match diff --git a/configs/gosdn.toml b/configs/gosdn.toml index fe17c7f6c72bd74dce8681c495555e6d6b9ddd37..afbf780236c9462c00718754062a595d26731418 100644 --- a/configs/gosdn.toml +++ b/configs/gosdn.toml @@ -1,5 +1 @@ CliSocket = ":55055" -db.socket = "bolt://172.17.0.4:7687" -db.user = "" -db.password = "" -db.crypto = false