From 71950479fbd6088f249e5fda3b180f294d1d745d Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 6 Feb 2018 00:35:39 +0100 Subject: Moves crawler to designated directory. --- config.go | 76 --------------------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 config.go (limited to 'config.go') diff --git a/config.go b/config.go deleted file mode 100644 index 2706201..0000000 --- a/config.go +++ /dev/null @@ -1,76 +0,0 @@ -package main - -import ( - log "github.com/Sirupsen/logrus" - "github.com/spf13/viper" -) - -type Config struct { - DBDriver string - DBDBName string - DBHost string - DBPort string - DBUser string - DBPassword string - DBOptions string - DBPath string // for sqlite - - Debug bool -} - -// Parses the configuration and sets the configuration struct. -func (c *Config) parseConfig(configFile string) { - - viper.SetDefault("DBDriver", "mysql") - viper.SetDefault("DBDBName", "alkobote") - viper.SetDefault("DBHost", "localhost") - viper.SetDefault("DBPort", "3306") - - viper.SetDefault("DBPath", "./alkobote.db") - - viper.SetDefault("Debug", false) - - // Name of the configuration file - viper.SetConfigName("config") - - // Where to find the config file - if configFile == "" { - viper.AddConfigPath("/etc/alkobote.de/") - viper.AddConfigPath(".") - viper.AddConfigPath("$HOME/.config/alkobote.de/") - viper.AddConfigPath("$HOME/alkobote.de/") - } else { - viper.AddConfigPath(configFile) - } - - // Env variables need to be prefixed with "ALKOBOTE_" - viper.SetEnvPrefix("ALKOBOTE") - - // Parses automatic the matching env variables - viper.AutomaticEnv() - - // Reads the config - err := viper.ReadInConfig() - if err != nil { - log.WithFields( - log.Fields{ - "error": err.Error(), - }, - ).Fatal("Fatal error config file") - } - - c.setsConfig() -} - -// Actually sets the config struct -func (c *Config) setsConfig() { - c.DBDriver = viper.GetString("DBDriver") - c.DBHost = viper.GetString("DBHost") - c.DBPort = viper.GetString("DBPort") - c.DBUser = viper.GetString("DBUser") - c.DBPassword = viper.GetString("DBPassword") - c.DBDBName = viper.GetString("DBDBName") - c.DBOptions = viper.GetString("DBOptions") - c.DBPath = viper.GetString("DBPath") - c.Debug = viper.GetBool("Debug") -} -- cgit v1.2.3