summaryrefslogtreecommitdiffstats
path: root/bridge/config/config.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-03-05 00:30:46 +0100
committerWim <wim@42.be>2018-03-05 00:30:46 +0100
commit98027446c895de648c65af33f2010c73c752a8da (patch)
tree98f42e35f2700f1e65015ced1df949fd3125bd77 /bridge/config/config.go
parentf2f1d874e1b4f997c111de87121eec98eef66381 (diff)
downloadmatterbridge-msglm-98027446c895de648c65af33f2010c73c752a8da.tar.gz
matterbridge-msglm-98027446c895de648c65af33f2010c73c752a8da.tar.bz2
matterbridge-msglm-98027446c895de648c65af33f2010c73c752a8da.zip
Fix tests and make megacheck happy
Diffstat (limited to 'bridge/config/config.go')
-rw-r--r--bridge/config/config.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/bridge/config/config.go b/bridge/config/config.go
index a89f9aa7..42a87f1c 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -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()