Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial add of zookeeper remote #198

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions remote/remote.go
Expand Up @@ -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()})
}
Expand Down
10 changes: 5 additions & 5 deletions viper.go
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down