Skip to content
Snippets Groups Projects
Commit 8d84398b authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

changed config path and cleaned up config

parent 4bc929eb
Branches
Tags
1 merge request!90Develop
Checking pipeline status
......@@ -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
......
CliSocket = ":55055"
db.socket = "bolt://172.17.0.4:7687"
db.user = ""
db.password = ""
db.crypto = false
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment