mirror of
https://github.com/spf13/viper
synced 2025-05-06 12:17:18 +00:00
Initial add of zookeeper remote
This commit is contained in:
parent
c1ccc378a0
commit
7822eb6fbc
3 changed files with 11 additions and 7 deletions
|
@ -25,7 +25,7 @@ and formats. It supports:
|
|||
* reading from JSON, TOML, YAML, HCL, and Java properties config files
|
||||
* live watching and re-reading of config files (optional)
|
||||
* reading from environment variables
|
||||
* reading from remote config systems (etcd or Consul), and watching changes
|
||||
* reading from remote config systems (etcd, Consul or zookeeper), and watching changes
|
||||
* reading from command line flags
|
||||
* reading from buffer
|
||||
* setting explicit values
|
||||
|
@ -320,7 +320,7 @@ package:
|
|||
`import _ "github.com/spf13/viper/remote"`
|
||||
|
||||
Viper will read a config string (as JSON, TOML, YAML or HCL) retrieved from a path
|
||||
in a Key/Value store such as etcd or Consul. These values take precedence over
|
||||
in a Key/Value store such as etcd, Consul or zookeeper. These values take precedence over
|
||||
default values, but are overridden by configuration values retrieved from disk,
|
||||
flags, or environment variables.
|
||||
|
||||
|
|
|
@ -55,12 +55,16 @@ func getConfigManager(rp viper.RemoteProvider) (crypt.ConfigManager, error) {
|
|||
}
|
||||
if rp.Provider() == "etcd" {
|
||||
cm, err = crypt.NewEtcdConfigManager([]string{rp.Endpoint()}, kr)
|
||||
} else if rp.Provider() == "zookeeper" {
|
||||
cm, err = crypt.NewZookeeperConfigManager([]string{rp.Endpoint()}, kr)
|
||||
} else {
|
||||
cm, err = crypt.NewConsulConfigManager([]string{rp.Endpoint()}, kr)
|
||||
}
|
||||
} else {
|
||||
if rp.Provider() == "etcd" {
|
||||
cm, err = crypt.NewStandardEtcdConfigManager([]string{rp.Endpoint()})
|
||||
} else if rp.Provider() == "zookeeper" {
|
||||
cm, err = crypt.NewStandardZookeeperConfigManager([]string{rp.Endpoint()})
|
||||
} else {
|
||||
cm, err = crypt.NewStandardConsulConfigManager([]string{rp.Endpoint()})
|
||||
}
|
||||
|
|
10
viper.go
10
viper.go
|
@ -62,7 +62,7 @@ func (str UnsupportedConfigError) Error() string {
|
|||
}
|
||||
|
||||
// Denotes encountering an unsupported remote
|
||||
// provider. Currently only etcd and Consul are
|
||||
// provider. Currently only etcd, Consul, zookeeper are
|
||||
// supported.
|
||||
type UnsupportedRemoteProviderError string
|
||||
|
||||
|
@ -179,7 +179,7 @@ func New() *Viper {
|
|||
func Reset() {
|
||||
v = New()
|
||||
SupportedExts = []string{"json", "toml", "yaml", "yml", "hcl"}
|
||||
SupportedRemoteProviders = []string{"etcd", "consul"}
|
||||
SupportedRemoteProviders = []string{"etcd", "consul", "zookeeper"}
|
||||
}
|
||||
|
||||
type defaultRemoteProvider struct {
|
||||
|
@ -220,7 +220,7 @@ type RemoteProvider interface {
|
|||
var SupportedExts []string = []string{"json", "toml", "yaml", "yml", "properties", "props", "prop", "hcl"}
|
||||
|
||||
// Universally supported remote providers.
|
||||
var SupportedRemoteProviders []string = []string{"etcd", "consul"}
|
||||
var SupportedRemoteProviders []string = []string{"etcd", "consul", "zookeeper"}
|
||||
|
||||
func OnConfigChange(run func(in fsnotify.Event)) { v.OnConfigChange(run) }
|
||||
func (v *Viper) OnConfigChange(run func(in fsnotify.Event)) {
|
||||
|
@ -326,7 +326,7 @@ func (v *Viper) AddConfigPath(in string) {
|
|||
|
||||
// AddRemoteProvider adds a remote configuration source.
|
||||
// Remote Providers are searched in the order they are added.
|
||||
// provider is a string value, "etcd" or "consul" are currently supported.
|
||||
// provider is a string value, "etcd", "consul" or "zookeeper" are currently supported.
|
||||
// endpoint is the url. etcd requires http://ip:port consul requires ip:port
|
||||
// path is the path in the k/v store to retrieve configuration
|
||||
// To retrieve a config file called myapp.json from /configs/myapp.json
|
||||
|
@ -355,7 +355,7 @@ func (v *Viper) AddRemoteProvider(provider, endpoint, path string) error {
|
|||
|
||||
// AddSecureRemoteProvider adds a remote configuration source.
|
||||
// Secure Remote Providers are searched in the order they are added.
|
||||
// provider is a string value, "etcd" or "consul" are currently supported.
|
||||
// provider is a string value, "etcd", "consul" or "zookeeper" are currently supported.
|
||||
// endpoint is the url. etcd requires http://ip:port consul requires ip:port
|
||||
// secretkeyring is the filepath to your openpgp secret keyring. e.g. /etc/secrets/myring.gpg
|
||||
// path is the path in the k/v store to retrieve configuration
|
||||
|
|
Loading…
Add table
Reference in a new issue