(obj interface{})
| 591 | } |
| 592 | |
| 593 | func WorkerKeyFunc(obj interface{}) (string, error) { |
| 594 | worker, ok := obj.(*corev1.Pod) |
| 595 | if !ok { |
| 596 | return "", fmt.Errorf("no support the type struct") |
| 597 | } |
| 598 | |
| 599 | objName, err := cache.ObjectToName(worker) |
| 600 | if err != nil { |
| 601 | return "", err |
| 602 | } |
| 603 | |
| 604 | ttyd := corev1.Container{} |
| 605 | for _, container := range worker.Spec.Containers { |
| 606 | if container.Name == "web-tty" { |
| 607 | ttyd = container |
| 608 | break |
| 609 | } |
| 610 | } |
| 611 | if len(ttyd.Image) == 0 { |
| 612 | return "", fmt.Errorf("web-tty container image not found") |
| 613 | } |
| 614 | |
| 615 | if len(objName.Namespace) > 0 { |
| 616 | return fmt.Sprintf("%s//%s//%s", objName.Namespace, ttyd.Image, objName.Name), nil |
| 617 | } |
| 618 | |
| 619 | return fmt.Sprintf("%s//%s", ttyd.Image, objName.Name), nil |
| 620 | } |
no outgoing calls
no test coverage detected