Allow configuration by environment
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This commit is contained in:
parent
38b4e0abdc
commit
4ef93fb6cf
1 changed files with 5 additions and 1 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"log"
|
"log"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/getsentry/sentry-go"
|
"github.com/getsentry/sentry-go"
|
||||||
|
@ -32,7 +33,8 @@ func Global() Configuration {
|
||||||
func Initialize() {
|
func Initialize() {
|
||||||
setDefaults()
|
setDefaults()
|
||||||
viper.SetConfigName("fermentord")
|
viper.SetConfigName("fermentord")
|
||||||
viper.SetConfigType("toml")
|
viper.SetEnvPrefix("fermentord")
|
||||||
|
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "__"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadConfiguration() Configuration {
|
func LoadConfiguration() Configuration {
|
||||||
|
@ -48,6 +50,8 @@ func LoadConfiguration() Configuration {
|
||||||
log.Printf("Error loading configuration: %v", err)
|
log.Printf("Error loading configuration: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
config := Configuration{}
|
config := Configuration{}
|
||||||
if err := viper.Unmarshal(&config); err != nil {
|
if err := viper.Unmarshal(&config); err != nil {
|
||||||
sentry.CaptureException(err)
|
sentry.CaptureException(err)
|
||||||
|
|
Loading…
Reference in a new issue