aboutsummaryrefslogtreecommitdiff
path: root/server/config
diff options
context:
space:
mode:
Diffstat (limited to 'server/config')
-rw-r--r--server/config/config.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/server/config/config.go b/server/config/config.go
index e6f1822..21fba94 100644
--- a/server/config/config.go
+++ b/server/config/config.go
@@ -1,6 +1,10 @@
package config
-import "github.com/spf13/viper"
+import (
+ "io"
+
+ "github.com/spf13/viper"
+)
// Config holds the values from the json config file.
type Config struct {
@@ -37,11 +41,11 @@ type SSH struct {
}
// ReadConfig parses a JSON configuration file into a Config struct.
-func ReadConfig(filename string) (*Config, error) {
+func ReadConfig(r io.Reader) (*Config, error) {
config := &Config{}
v := viper.New()
- v.SetConfigFile(filename)
- if err := v.ReadInConfig(); err != nil {
+ v.SetConfigType("json")
+ if err := v.ReadConfig(r); err != nil {
return nil, err
}
if err := v.Unmarshal(config); err != nil {