Retrieve the first found remote configuration.
()
| 208 | |
| 209 | // Retrieve the first found remote configuration. |
| 210 | func (v *Viper) watchKeyValueConfigOnChannel() error { |
| 211 | if len(v.remoteProviders) == 0 { |
| 212 | return RemoteConfigError("No Remote Providers") |
| 213 | } |
| 214 | |
| 215 | for _, rp := range v.remoteProviders { |
| 216 | respc, _ := RemoteConfig.WatchChannel(rp) |
| 217 | // Todo: Add quit channel |
| 218 | go func(rc <-chan *RemoteResponse) { |
| 219 | for { |
| 220 | b := <-rc |
| 221 | reader := bytes.NewReader(b.Value) |
| 222 | err := v.unmarshalReader(reader, v.kvstore) |
| 223 | if err != nil { |
| 224 | v.logger.Error(fmt.Errorf("failed to unmarshal remote config: %w", err).Error()) |
| 225 | } |
| 226 | } |
| 227 | }(respc) |
| 228 | return nil |
| 229 | } |
| 230 | return RemoteConfigError("No Files Found") |
| 231 | } |
| 232 | |
| 233 | // Retrieve the first found remote configuration. |
| 234 | func (v *Viper) watchKeyValueConfig() error { |
no test coverage detected