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"
|
||||
_ "embed"
|
||||
"log"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/getsentry/sentry-go"
|
||||
|
@ -32,7 +33,8 @@ func Global() Configuration {
|
|||
func Initialize() {
|
||||
setDefaults()
|
||||
viper.SetConfigName("fermentord")
|
||||
viper.SetConfigType("toml")
|
||||
viper.SetEnvPrefix("fermentord")
|
||||
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "__"))
|
||||
}
|
||||
|
||||
func LoadConfiguration() Configuration {
|
||||
|
@ -48,6 +50,8 @@ func LoadConfiguration() Configuration {
|
|||
log.Printf("Error loading configuration: %v", err)
|
||||
}
|
||||
|
||||
viper.AutomaticEnv()
|
||||
|
||||
config := Configuration{}
|
||||
if err := viper.Unmarshal(&config); err != nil {
|
||||
sentry.CaptureException(err)
|
||||
|
|
Loading…
Reference in a new issue