Skip to content

Commit

Permalink
Merge branch 'main' into jose/issues-50
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAngel1196 authored Oct 25, 2023
2 parents 965ffdb + 43cade8 commit 9037176
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ func GetUserConfig(configFile string) (Config, error) {
}
viper.SetConfigFile(configFile)
if err := viper.ReadInConfig(); err != nil {
log.Fatal().Err(err).Msg("Error reading config file.")
log.Error().Err(err).Msg("Error reading config file.")
return Config{}, err
}

// (Optionally) Load a .env file
if fileExists("./.env") {
viper.SetConfigFile("./.env")
viper.SetConfigType("env")
if err := viper.ReadInConfig(); err != nil {
if err := viper.MergeInConfig(); err != nil {
log.Error().Err(err).Msg("Error loading .env file.")
}
} else {
Expand All @@ -78,8 +79,9 @@ func GetUserConfig(configFile string) (Config, error) {
viper.SetEnvPrefix("vulnbot")
viper.AutomaticEnv()

// Finally, copy all loaded values into the config object
_ = viper.Unmarshal(&userCfg)
if err := viper.Unmarshal(&userCfg); err != nil {
return Config{}, err
}

return userCfg, nil
}
Expand Down

0 comments on commit 9037176

Please sign in to comment.