@@ -21,6 +21,7 @@ type remoteConfigFactory interface {
2121 WatchChannel (rp RemoteProvider ) (<- chan * RemoteResponse , chan bool )
2222}
2323
24+ // RemoteResponse represents a response from a remote configuration provider.
2425type RemoteResponse struct {
2526 Value []byte
2627 Error error
@@ -93,6 +94,14 @@ func AddRemoteProvider(provider, endpoint, path string) error {
9394 return v .AddRemoteProvider (provider , endpoint , path )
9495}
9596
97+ // AddRemoteProvider adds a remote configuration source.
98+ // Remote Providers are searched in the order they are added.
99+ // provider is a string value: "etcd", "etcd3", "consul", "firestore" or "nats" are currently supported.
100+ // endpoint is the url. etcd requires http://ip:port, consul requires ip:port, nats requires nats://ip:port
101+ // path is the path in the k/v store to retrieve configuration
102+ // To retrieve a config file called myapp.json from /configs/myapp.json
103+ // you should set path to /configs and set config name (SetConfigName()) to
104+ // "myapp".
96105func (v * Viper ) AddRemoteProvider (provider , endpoint , path string ) error {
97106 if ! slices .Contains (SupportedRemoteProviders , provider ) {
98107 return UnsupportedRemoteProviderError (provider )
@@ -126,6 +135,16 @@ func AddSecureRemoteProvider(provider, endpoint, path, secretkeyring string) err
126135 return v .AddSecureRemoteProvider (provider , endpoint , path , secretkeyring )
127136}
128137
138+ // AddSecureRemoteProvider adds a remote configuration source.
139+ // Secure Remote Providers are searched in the order they are added.
140+ // provider is a string value: "etcd", "etcd3", "consul", "firestore" or "nats" are currently supported.
141+ // endpoint is the url. etcd requires http://ip:port consul requires ip:port
142+ // secretkeyring is the filepath to your openpgp secret keyring. e.g. /etc/secrets/myring.gpg
143+ // path is the path in the k/v store to retrieve configuration
144+ // To retrieve a config file called myapp.json from /configs/myapp.json
145+ // you should set path to /configs and set config name (SetConfigName()) to
146+ // "myapp".
147+ // Secure Remote Providers are implemented with github.com/sagikazarmark/crypt.
129148func (v * Viper ) AddSecureRemoteProvider (provider , endpoint , path , secretkeyring string ) error {
130149 if ! slices .Contains (SupportedRemoteProviders , provider ) {
131150 return UnsupportedRemoteProviderError (provider )
@@ -159,15 +178,21 @@ func (v *Viper) providerPathExists(p *defaultRemoteProvider) bool {
159178// and read it in the remote configuration registry.
160179func ReadRemoteConfig () error { return v .ReadRemoteConfig () }
161180
181+ // ReadRemoteConfig attempts to get configuration from a remote source
182+ // and read it in the remote configuration registry.
162183func (v * Viper ) ReadRemoteConfig () error {
163184 return v .getKeyValueConfig ()
164185}
165186
187+ // WatchRemoteConfig updates configuration from available remote providers.
166188func WatchRemoteConfig () error { return v .WatchRemoteConfig () }
189+
190+ // WatchRemoteConfig updates configuration from available remote providers.
167191func (v * Viper ) WatchRemoteConfig () error {
168192 return v .watchKeyValueConfig ()
169193}
170194
195+ // WatchRemoteConfigOnChannel updates configuration from available remote providers.
171196func (v * Viper ) WatchRemoteConfigOnChannel () error {
172197 return v .watchKeyValueConfigOnChannel ()
173198}
0 commit comments