Skip to content

Commit

Permalink
fixed replace port from env
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Zatonskiy committed Aug 1, 2023
1 parent 358b353 commit aee1b8a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,24 @@ func (b *Bundle) providePreRunner(
logger *zap.Logger,
registry *prometheus.Registry,
) (_ glue.PreRunner, _ func() error, err error) {
// use this hack for UnmarshalKey
// see https://github.com/spf13/viper/issues/188
var configPath = BundleName
var cfgPath = cfg.Sub(configPath)
if cfgPath != nil {
for _, key := range cfg.Sub(configPath).AllKeys() {
key = configPath + "." + key
cfg.Set(key, cfg.Get(key))
}
}

var conf = struct {
Host string `mapstructure:"host"`
Port string `mapstructure:"port"`
Path string `mapstructure:"path"`
}{}

if err = cfg.UnmarshalKey(BundleName, &conf); err != nil {
if err = cfg.UnmarshalKey(configPath, &conf); err != nil {
return nil, nil, err
}

Expand Down

0 comments on commit aee1b8a

Please sign in to comment.