mirror of
https://github.com/spf13/viper
synced 2024-12-23 03:57:01 +00:00
Updated getKeyValueConfig to allow multiple config files from the same remote vendor
This commit is contained in:
parent
d8a428b8a3
commit
eb33902d94
1 changed files with 9 additions and 11 deletions
20
viper.go
20
viper.go
|
@ -1106,16 +1106,14 @@ func (v *Viper) getKeyValueConfig() error {
|
||||||
if RemoteConfig == nil {
|
if RemoteConfig == nil {
|
||||||
return RemoteConfigError("Enable the remote features by doing a blank import of the viper/remote package: '_ github.com/spf13/viper/remote'")
|
return RemoteConfigError("Enable the remote features by doing a blank import of the viper/remote package: '_ github.com/spf13/viper/remote'")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rp := range v.remoteProviders {
|
for _, rp := range v.remoteProviders {
|
||||||
val, err := v.getRemoteConfig(rp)
|
val, err := v.getRemoteConfig(rp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
v.kvstore = val
|
v.kvstore = val
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return RemoteConfigError("No Files Found")
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Viper) getRemoteConfig(provider *defaultRemoteProvider) (map[string]interface{}, error) {
|
func (v *Viper) getRemoteConfig(provider *defaultRemoteProvider) (map[string]interface{}, error) {
|
||||||
|
@ -1155,36 +1153,36 @@ func AllKeys() []string { return v.AllKeys() }
|
||||||
func (v *Viper) AllKeys() []string {
|
func (v *Viper) AllKeys() []string {
|
||||||
m := map[string]struct{}{}
|
m := map[string]struct{}{}
|
||||||
|
|
||||||
for key, _ := range v.defaults {
|
for key := range v.defaults {
|
||||||
m[strings.ToLower(key)] = struct{}{}
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, _ := range v.pflags {
|
for key := range v.pflags {
|
||||||
m[strings.ToLower(key)] = struct{}{}
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, _ := range v.env {
|
for key := range v.env {
|
||||||
m[strings.ToLower(key)] = struct{}{}
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, _ := range v.config {
|
for key := range v.config {
|
||||||
m[strings.ToLower(key)] = struct{}{}
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, _ := range v.kvstore {
|
for key := range v.kvstore {
|
||||||
m[strings.ToLower(key)] = struct{}{}
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, _ := range v.override {
|
for key := range v.override {
|
||||||
m[strings.ToLower(key)] = struct{}{}
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, _ := range v.aliases {
|
for key := range v.aliases {
|
||||||
m[strings.ToLower(key)] = struct{}{}
|
m[strings.ToLower(key)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
a := []string{}
|
a := []string{}
|
||||||
for x, _ := range m {
|
for x := range m {
|
||||||
a = append(a, x)
|
a = append(a, x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue