This fixes it; more detail incoming
Peter Bourgon
7 years ago
121 | 121 | return nil, err |
122 | 122 | } |
123 | 123 | |
124 | // Special case. Note that it's possible that len(resp.Node.Nodes) == 0 and | |
125 | // resp.Node.Value is also empty, in which case the key is empty and we | |
126 | // should not return any entries. | |
127 | if len(resp.Node.Nodes) == 0 && resp.Node.Value != "" { | |
128 | return []string{resp.Node.Value}, nil | |
129 | } | |
130 | ||
124 | 131 | entries := make([]string, len(resp.Node.Nodes)) |
125 | ||
126 | if len(entries) > 0 { | |
127 | for i, node := range resp.Node.Nodes { | |
128 | entries[i] = node.Value | |
129 | } | |
130 | } else { | |
131 | entries = append(entries, resp.Node.Value) | |
132 | for i, node := range resp.Node.Nodes { | |
133 | entries[i] = node.Value | |
132 | 134 | } |
133 | 135 | return entries, nil |
134 | ||
135 | 136 | } |
136 | 137 | |
137 | 138 | // WatchPrefix implements the etcd Client interface. |
138 | 139 | func (c *client) WatchPrefix(prefix string, responseChan chan *etcd.Response) { |
139 | 140 | watch := c.keysAPI.Watcher(prefix, &etcd.WatcherOptions{AfterIndex: 0, Recursive: true}) |
141 | responseChan <- nil // TODO(pb) explain this | |
140 | 142 | for { |
141 | 143 | res, err := watch.Next(c.ctx) |
142 | 144 | if err != nil { |