// waitForPodToComeUp waits for a pod matching `selector` to come up in `namespace`, and returns it.
waitForPodToComeUp waits for a pod matching `selector` to come up in `namespace`, and returns it.
// waitForPodToComeUp waits for a pod matching ` selector ` to come up in ` namespace ` and returns it .
func waitForPodToComeUp(t *testing.T, namespace, selector string, pollOps ...poll.SettingOp) (pod *corev1.Pod) {
	client := kubeClient(t)
	listOptions := metav1.ListOptions{LabelSelector: selector}
	pollingFunc := func(_ poll.LogT) poll.Result {
		podList, err := client.CoreV1().Pods(namespace).List(context.Background(), listOptions)
		if err != nil {
			return poll.Error(err)
		}
		switch len(podList.Items) {
		case 0:
			return poll.Continue("no pod matching %s in namespace %s", selector, namespace)
		case 1:
			pod = &podList.Items[0]
			return poll.Success()
		default:
			err = fmt.Errorf("expected no more than 1 pod matching %s in namespace %s, found %d",
				selector, namespace, len(podList.Items))
			return poll.Error(err)
		}
	}
	poll.WaitOn(t, pollingFunc, pollOps...)
	return
}
func waitForPodToComeUp ( t * testing . T , namespace , selector string , pollOps ... poll . SettingOp ) ( pod * corev1 . Pod ) { client := kubeClient ( t ) listOptions := metav1 . ListOptions { LabelSelector : selector } pollingFunc := func ( _ poll . LogT ) poll . Result { podList , err := client . CoreV1 ( ) . Pods ( namespace ) . List ( context . Background ( ) , listOptions ) if err != nil { return poll . Error ( err ) } switch len ( podList . Items ) { case 0 : return poll . Continue ( " " , selector , namespace ) case 1 : pod = & podList . Items [ 0 ] return poll . Success ( ) default : err = fmt . Errorf ( " " , selector , namespace , len ( podList . Items ) ) return poll . Error ( err ) } } poll . WaitOn ( t , pollingFunc , pollOps ... ) return }
waitForPodToComeUp waits for a pod matching `selector` to come up in `namespace`, and returns it.
waitForPodToComeUp waits for a pod matching ` selector ` to come up in ` namespace ` and returns it .