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

Function WorkerKeyFunc

pkg/workerpool/worker_pool.go:593–620  ·  view source on GitHub ↗
(obj interface{})

Source from the content-addressed store, hash-verified

591}
592
593func 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}

Callers 4

reconcileMethod · 0.85
scaleInWorkerQueueMethod · 0.85
BorrowMethod · 0.85
BackMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected