Add README.md for Consul remote provider (#489) - viper - [fork] go viper port for 9front
(HTM) git clone git@git.drkhsh.at/viper.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 8addaed22d65eb9b54dc9e9a28537f5b8b9ca756
(DIR) parent 05116ad639474f7858b82b48004bfbdb4c51e367
(HTM) Author: Adhatama <am.adhatama@gmail.com>
Date: Wed, 29 Aug 2018 05:05:06 +0700
Add README.md for Consul remote provider (#489)
Diffstat:
M README.md | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/README.md b/README.md
@@ -373,12 +373,33 @@ how to use Consul.
### Remote Key/Value Store Example - Unencrypted
+#### etcd
```go
viper.AddRemoteProvider("etcd", "http://127.0.0.1:4001","/config/hugo.json")
viper.SetConfigType("json") // because there is no file extension in a stream of bytes, supported extensions are "json", "toml", "yaml", "yml", "properties", "props", "prop"
err := viper.ReadRemoteConfig()
```
+#### Consul
+You need to set a key to Consul key/value storage with JSON value containing your desired config.
+For example, create a Consul key/value store key `MY_CONSUL_KEY` with value:
+
+```json
+{
+ "port": 8080,
+ "hostname": "myhostname.com"
+}
+```
+
+```go
+viper.AddRemoteProvider("consul", "localhost:8500", "MY_CONSUL_KEY")
+viper.SetConfigType("json") // Need to explicitly set this to json
+err := viper.ReadRemoteConfig()
+
+fmt.Println(viper.Get("port")) // 8080
+fmt.Println(viper.Get("hostname")) // myhostname.com
+```
+
### Remote Key/Value Store Example - Encrypted
```go