Skip to content

Commit

Permalink
Allow viper automatic env vars with AUTH0_GW prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanIrimie authored Nov 24, 2023
2 parents 4cb6eab + e0f66b8 commit 09709cd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"strings"
"time"

"github.com/mitchellh/mapstructure"
Expand Down Expand Up @@ -55,12 +56,17 @@ func Load(file string) (*Config, error) {
v.AddConfigPath(".")
v.SetConfigFile(file)

v.SetEnvPrefix("AUTH0_GW")
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))

v.SetDefault("scheduler.interval", "5m")

if err := v.ReadInConfig(); err != nil {
return nil, errors.Wrapf(err, "loading config file %s", file)
}

v.AutomaticEnv()

cfg := &Config{}
err := v.UnmarshalExact(cfg, func(dc *mapstructure.DecoderConfig) {
dc.TagName = "json"
Expand Down

0 comments on commit 09709cd

Please sign in to comment.