SplitWorkerKey returns the namespace, name, image that WorkerKeyFunc encoded into key. packing/unpacking won't be necessary.
(key string)
| 577 | // |
| 578 | // packing/unpacking won't be necessary. |
| 579 | func 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 | |
| 593 | func WorkerKeyFunc(obj interface{}) (string, error) { |
| 594 | worker, ok := obj.(*corev1.Pod) |