4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-27 18:09:26 +00:00

Fix tests and make megacheck happy

This commit is contained in:
Wim
2018-03-05 00:30:46 +01:00
parent f2f1d874e1
commit 98027446c8
4 changed files with 29 additions and 34 deletions

View File

@ -1,6 +1,7 @@
package config
import (
"bytes"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"os"
@ -192,6 +193,23 @@ func NewConfig(cfgfile string) *Config {
return mycfg
}
func NewConfigFromString(input []byte) *Config {
var cfg ConfigValues
viper.SetConfigType("toml")
err := viper.ReadConfig(bytes.NewBuffer(input))
if err != nil {
log.Fatal(err)
}
err = viper.Unmarshal(&cfg)
if err != nil {
log.Fatal(err)
}
mycfg := new(Config)
mycfg.v = viper.GetViper()
mycfg.ConfigValues = &cfg
return mycfg
}
func (c *Config) GetBool(key string) bool {
c.RLock()
defer c.RUnlock()