From 8d84398b1040729a8cab4851358f646baec9f475 Mon Sep 17 00:00:00 2001 From: Manuel Kieweg <manuel.kieweg@h-da.de> Date: Mon, 22 Mar 2021 16:15:19 +0000 Subject: [PATCH] changed config path and cleaned up config --- cmd/root.go | 18 ++++-------------- configs/gosdn.toml | 4 ---- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 236c501e9..4ee3a3b26 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 fe17c7f6c..afbf78023 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 -- GitLab