MCPcopy Create free account
hub / github.com/cloudtty/cloudtty / SplitWorkerKey

Function SplitWorkerKey

pkg/workerpool/worker_pool.go:579–591  ·  view source on GitHub ↗

SplitWorkerKey returns the namespace, name, image that WorkerKeyFunc encoded into key. packing/unpacking won't be necessary.

(key string)

Source from the content-addressed store, hash-verified

577//
578// packing/unpacking won't be necessary.
579func SplitWorkerKey(key string) (namespace, name, image string, err error) {
580 parts := strings.Split(key, "//")
581 switch len(parts) {
582 case 2:
583 // name only, no namespace
584 return "", parts[1], parts[0], nil
585 case 3:
586 // namespace and name
587 return parts[0], parts[2], parts[1], nil
588 }
589
590 return "", "", "", fmt.Errorf("unexpected key format: %q", key)
591}
592
593func WorkerKeyFunc(obj interface{}) (string, error) {
594 worker, ok := obj.(*corev1.Pod)

Callers 1

matchWorkerForMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected