onlyIDQuery returns true if the query contains only a non-empty ID and all others keys are empty
(q *protocol.KontrolQuery)
| 316 | // onlyIDQuery returns true if the query contains only a non-empty ID and all |
| 317 | // others keys are empty |
| 318 | func onlyIDQuery(q *protocol.KontrolQuery) bool { |
| 319 | fields := q.Fields() |
| 320 | |
| 321 | // check if any other key exist, if yes return a false |
| 322 | for _, k := range keyOrder { |
| 323 | v := fields[k] |
| 324 | if k != "id" && v != "" { |
| 325 | return false |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | // now all other keys are empty, check finally for our ID |
| 330 | if fields["id"] != "" { |
| 331 | return true |
| 332 | } |
| 333 | |
| 334 | // ID is empty too! |
| 335 | return false |
| 336 | } |
| 337 | |
| 338 | // getQueryKey returns the etcd key for the query. |
| 339 | func GetQueryKey(q *protocol.KontrolQuery) (string, error) { |