ReadBytes reads the contents of a key from etcd and returns the bytes.
()
| 37 | |
| 38 | // ReadBytes reads the contents of a key from etcd and returns the bytes. |
| 39 | func (r *ETCD) ReadBytes() ([]byte, error) { |
| 40 | client, err := clientv3.New(r.clientConfig) |
| 41 | if err != nil { |
| 42 | return nil, err |
| 43 | } |
| 44 | defer client.Close() |
| 45 | |
| 46 | resp, err := client.Get(r.context(), r.key) |
| 47 | if err != nil { |
| 48 | return nil, err |
| 49 | } |
| 50 | if resp.Count == 0 { |
| 51 | return nil, fmt.Errorf("no such config key: %s", r.key) |
| 52 | } |
| 53 | r.rev = resp.Header.Revision |
| 54 | return resp.Kvs[0].Value, nil |
| 55 | } |
| 56 | |
| 57 | // Read is not supported by the remote provider. |
| 58 | func (r *ETCD) Read() (map[string]interface{}, error) { |