summaryrefslogtreecommitdiff
path: root/cmd/rr/utils/config.go
blob: e7e22b3ab63ea1e35c109645a5bbba5aa43875a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package utils

import (
	"github.com/spf13/viper"
	"github.com/spiral/roadrunner/service"
)

type ConfigWrapper struct {
	Viper *viper.Viper
}

func (w *ConfigWrapper) Get(key string) service.Config {
	sub := w.Viper.Sub(key)
	if sub == nil {
		return nil
	}

	return &ConfigWrapper{sub}
}

func (w *ConfigWrapper) Unmarshal(out interface{}) error {
	return w.Viper.Unmarshal(out)
}