MCPcopy Index your code
hub / github.com/koding/kite / GetQueryKey

Function GetQueryKey

kontrol/etcd.go:339–372  ·  view source on GitHub ↗

getQueryKey returns the etcd key for the query.

(q *protocol.KontrolQuery)

Source from the content-addressed store, hash-verified

337
338// getQueryKey returns the etcd key for the query.
339func GetQueryKey(q *protocol.KontrolQuery) (string, error) {
340 fields := q.Fields()
341
342 if q.Username == "" {
343 return "", errors.New("Empty username field")
344 }
345
346 // Validate query and build key.
347 path := "/"
348
349 empty := false // encountered with empty field?
350 empytField := "" // for error log
351
352 // http://golang.org/doc/go1.3#map, order is important and we can't rely on
353 // maps because the keys are not ordered :)
354 for _, key := range keyOrder {
355 v := fields[key]
356 if v == "" {
357 empty = true
358 empytField = key
359 continue
360 }
361
362 if empty && v != "" {
363 return "", fmt.Errorf("Invalid query. Query option is not set: %s", empytField)
364 }
365
366 path = path + v + "/"
367 }
368
369 path = strings.TrimSuffix(path, "/")
370
371 return path, nil
372}
373
374func getAudience(q *protocol.KontrolQuery) string {
375 if q.Name != "" {

Callers 3

GetMethod · 0.85
etcdKeyMethod · 0.85
TestGetQueryKeyFunction · 0.85

Calls 1

FieldsMethod · 0.80

Tested by 1

TestGetQueryKeyFunction · 0.68