mirror of
https://github.com/spf13/viper
synced 2024-11-04 20:27:02 +00:00
MarshallReader -> marshalReader
This commit is contained in:
parent
18a87c05c6
commit
91b076eec5
2 changed files with 11 additions and 11 deletions
8
viper.go
8
viper.go
|
@ -528,7 +528,7 @@ func (v *viper) ReadInConfig() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
v.MarshallReader(bytes.NewReader(file), v.config)
|
v.marshalReader(bytes.NewReader(file), v.config)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,8 +543,8 @@ func (v *viper) ReadRemoteConfig() error {
|
||||||
|
|
||||||
// Marshall a Reader into a map
|
// Marshall a Reader into a map
|
||||||
// Should probably be an unexported function
|
// Should probably be an unexported function
|
||||||
func MarshallReader(in io.Reader, c map[string]interface{}) { v.MarshallReader(in, c) }
|
func marshalReader(in io.Reader, c map[string]interface{}) { v.marshalReader(in, c) }
|
||||||
func (v *viper) MarshallReader(in io.Reader, c map[string]interface{}) {
|
func (v *viper) marshalReader(in io.Reader, c map[string]interface{}) {
|
||||||
marshallConfigReader(in, c, v.getConfigType())
|
marshallConfigReader(in, c, v.getConfigType())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +598,7 @@ func (v *viper) getRemoteConfig(provider *remoteProvider) (map[string]interface{
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
reader := bytes.NewReader(b)
|
reader := bytes.NewReader(b)
|
||||||
v.MarshallReader(reader, v.kvstore)
|
v.marshalReader(reader, v.kvstore)
|
||||||
return v.kvstore, err
|
return v.kvstore, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ func TestMarshalling(t *testing.T) {
|
||||||
SetConfigType("yaml")
|
SetConfigType("yaml")
|
||||||
r := bytes.NewReader(yamlExample)
|
r := bytes.NewReader(yamlExample)
|
||||||
|
|
||||||
MarshallReader(r, v.config)
|
marshalReader(r, v.config)
|
||||||
assert.True(t, InConfig("name"))
|
assert.True(t, InConfig("name"))
|
||||||
assert.False(t, InConfig("state"))
|
assert.False(t, InConfig("state"))
|
||||||
assert.Equal(t, "steve", Get("name"))
|
assert.Equal(t, "steve", Get("name"))
|
||||||
|
@ -143,7 +143,7 @@ func TestYML(t *testing.T) {
|
||||||
SetConfigType("yml")
|
SetConfigType("yml")
|
||||||
r := bytes.NewReader(yamlExample)
|
r := bytes.NewReader(yamlExample)
|
||||||
|
|
||||||
MarshallReader(r, v.config)
|
marshalReader(r, v.config)
|
||||||
assert.Equal(t, "steve", Get("name"))
|
assert.Equal(t, "steve", Get("name"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ func TestJSON(t *testing.T) {
|
||||||
SetConfigType("json")
|
SetConfigType("json")
|
||||||
r := bytes.NewReader(jsonExample)
|
r := bytes.NewReader(jsonExample)
|
||||||
|
|
||||||
MarshallReader(r, v.config)
|
marshalReader(r, v.config)
|
||||||
assert.Equal(t, "0001", Get("id"))
|
assert.Equal(t, "0001", Get("id"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,17 +159,17 @@ func TestTOML(t *testing.T) {
|
||||||
SetConfigType("toml")
|
SetConfigType("toml")
|
||||||
r := bytes.NewReader(tomlExample)
|
r := bytes.NewReader(tomlExample)
|
||||||
|
|
||||||
MarshallReader(r, v.config)
|
marshalReader(r, v.config)
|
||||||
assert.Equal(t, "TOML Example", Get("title"))
|
assert.Equal(t, "TOML Example", Get("title"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRemotePrecedence(t *testing.T) {
|
func TestRemotePrecedence(t *testing.T) {
|
||||||
SetConfigType("json")
|
SetConfigType("json")
|
||||||
r := bytes.NewReader(jsonExample)
|
r := bytes.NewReader(jsonExample)
|
||||||
MarshallReader(r, v.config)
|
marshalReader(r, v.config)
|
||||||
remote := bytes.NewReader(remoteExample)
|
remote := bytes.NewReader(remoteExample)
|
||||||
assert.Equal(t, "0001", Get("id"))
|
assert.Equal(t, "0001", Get("id"))
|
||||||
MarshallReader(remote, v.kvstore)
|
marshalReader(remote, v.kvstore)
|
||||||
assert.Equal(t, "0001", Get("id"))
|
assert.Equal(t, "0001", Get("id"))
|
||||||
assert.NotEqual(t, "cronut", Get("type"))
|
assert.NotEqual(t, "cronut", Get("type"))
|
||||||
assert.Equal(t, "remote", Get("newkey"))
|
assert.Equal(t, "remote", Get("newkey"))
|
||||||
|
@ -182,7 +182,7 @@ func TestRemotePrecedence(t *testing.T) {
|
||||||
func TestEnv(t *testing.T) {
|
func TestEnv(t *testing.T) {
|
||||||
SetConfigType("json")
|
SetConfigType("json")
|
||||||
r := bytes.NewReader(jsonExample)
|
r := bytes.NewReader(jsonExample)
|
||||||
MarshallReader(r, v.config)
|
marshalReader(r, v.config)
|
||||||
BindEnv("id")
|
BindEnv("id")
|
||||||
BindEnv("f", "FOOD")
|
BindEnv("f", "FOOD")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue