(path string, must bool)
| 201 | } |
| 202 | |
| 203 | func (c *Client) List(path string, must bool) ([]string, error) { |
| 204 | c.Lock() |
| 205 | defer c.Unlock() |
| 206 | if c.closed { |
| 207 | return nil, errors.Trace(ErrClosedClient) |
| 208 | } |
| 209 | cntx, cancel := c.newContext() |
| 210 | defer cancel() |
| 211 | r, err := c.kapi.Get(cntx, path, &client.GetOptions{Quorum: true}) |
| 212 | switch { |
| 213 | case err != nil: |
| 214 | if isErrNoNode(err) && !must { |
| 215 | return nil, nil |
| 216 | } |
| 217 | log.Debugf("etcd list node %s failed: %s", path, err) |
| 218 | return nil, errors.Trace(err) |
| 219 | case !r.Node.Dir: |
| 220 | log.Debugf("etcd list node %s failed: not a dir", path) |
| 221 | return nil, errors.Trace(ErrNotDir) |
| 222 | default: |
| 223 | var paths []string |
| 224 | for _, node := range r.Node.Nodes { |
| 225 | paths = append(paths, node.Key) |
| 226 | } |
| 227 | return paths, nil |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | func (c *Client) CreateEphemeral(path string, data []byte) (<-chan struct{}, error) { |
| 232 | c.Lock() |
nothing calls this directly
no test coverage detected