mirror of
https://github.com/spf13/viper
synced 2024-12-22 19:47:01 +00:00
add support for consul
This commit is contained in:
parent
51da30f655
commit
563f4d44c4
1 changed files with 10 additions and 13 deletions
19
viper.go
19
viper.go
|
@ -523,17 +523,6 @@ func (rce RemoteConfigError) Error() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRemoteConfig(provider *remoteProvider) (map[string]interface{}, error) {
|
func getRemoteConfig(provider *remoteProvider) (map[string]interface{}, error) {
|
||||||
switch provider.provider {
|
|
||||||
case "etcd":
|
|
||||||
return getEtcdConfig(provider)
|
|
||||||
case "consul":
|
|
||||||
// not implemented yet
|
|
||||||
|
|
||||||
}
|
|
||||||
return config, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getEtcdConfig(provider *remoteProvider) (map[string]interface{}, error) {
|
|
||||||
var cm crypt.ConfigManager
|
var cm crypt.ConfigManager
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@ -543,9 +532,17 @@ func getEtcdConfig(provider *remoteProvider) (map[string]interface{}, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if provider.provider == "etcd" {
|
||||||
cm, err = crypt.NewEtcdConfigManager([]string{provider.endpoint}, kr)
|
cm, err = crypt.NewEtcdConfigManager([]string{provider.endpoint}, kr)
|
||||||
} else {
|
} else {
|
||||||
|
cm, err = crypt.NewConsulConfigManager([]string{provider.endpoint}, kr)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if provider.provider == "etcd" {
|
||||||
cm, err = crypt.NewStandardEtcdConfigManager([]string{provider.endpoint})
|
cm, err = crypt.NewStandardEtcdConfigManager([]string{provider.endpoint})
|
||||||
|
} else {
|
||||||
|
cm, err = crypt.NewStandardConsulConfigManager([]string{provider.endpoint})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue