github.com/xmidt-org/webpa-common@v1.11.9/device/viper.go (about) 1 package device 2 3 import ( 4 "github.com/go-kit/kit/log" 5 "github.com/spf13/viper" 6 ) 7 8 const ( 9 // DeviceManagerKey is the Viper subkey under which device.Options are typically stored 10 // In a JSON configuration file, this will be expressed as: 11 // 12 // { 13 // /* other stuff can be here */ 14 // 15 // "device": { 16 // "manager": { 17 // } 18 // } 19 // } 20 DeviceManagerKey = "device.manager" 21 ) 22 23 // NewOptions unmarshals a device.Options from a Viper environment. Listeners 24 // must be configured separately. 25 func NewOptions(logger log.Logger, v *viper.Viper) (o *Options, err error) { 26 o = new(Options) 27 if v != nil { 28 err = v.Unmarshal(o) 29 } 30 31 o.Logger = logger 32 return 33 }