Compare commits

...

2 Commits

Author SHA1 Message Date
b419cfde69
Fix workaround for optional config file with Viper
There was a false error reported when the configuration file was found
2022-09-08 00:59:10 -05:00
534b3e5fcd
Bind config file in Docker 2022-09-08 00:57:10 -05:00
2 changed files with 7 additions and 4 deletions

View File

@ -126,14 +126,14 @@ func setupConfig() {
viper.SetConfigType("toml")
viper.AddConfigPath(".")
err = viper.ReadInConfig()
viper.BindEnv("DEBUG")
viper.BindEnv("DISCORD_TOKEN")
viper.BindEnv("OPEN_WEATHER_MAP_TOKEN")
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
log.Fatalf("fatal error config file: %v", err)
if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
log.Fatalf("fatal error config file: %v", err)
}
}
err = viper.Unmarshal(&C)

View File

@ -1,3 +1,4 @@
---
version: "3.9"
services:
bot:
@ -6,3 +7,5 @@ services:
- BEEPBOOP_DISCORD_TOKEN
- BEEPBOOP_OPEN_WEATHER_MAP_TOKEN
- BEEPBOOP_DEBUG=true
volumes:
- ./config.toml:/config.toml