func (t *Tunnel) waitForPodReady(ctx context.Context, podName string) error {
	clientSet := kubernetes.New(t.client)
	factory := informers.NewSharedInformerFactoryWithOptions(
		clientSet,
		time.Minute,
		informers.WithNamespace(t.Namespace),
	)
	informer := factory.Core().V1().Pods().Informer()

	stopChan := make(chan struct{})
	eventChan := make(chan error)
	defer close(stopChan)
	defer close(eventChan)

	informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc: func(obj interface{}) {
			objPod, valid := obj.(*corev1.Pod)
			if !valid {
				eventChan <- errors.New("expected valid pod for informer")
				return
			}

			if objPod.Name == podName && pod.IsPodRunning(objPod) {
				eventChan <- nil
			}
		},
		UpdateFunc: func(oldObj, newObj interface{}) {
			objPod, valid := newObj.(*corev1.Pod)
			if !valid {
				eventChan <- errors.New("expected valid pod for informer")
				return
			}

			if objPod.Name == podName && pod.IsPodRunning(objPod) {
				eventChan <- nil
			}
		},
		DeleteFunc: func(obj interface{}) {
			pod, valid := obj.(*corev1.Pod)
			if !valid {
				eventChan <- errors.New("expected valid pod for informer")
				return
			}

			if pod.Name == podName {
				eventChan <- errors.Errorf("tunnel pod %s is being deleted", podName)
			}
		},
	})

	go informer.Run(stopChan)

	select {
	case <-ctx.Done():
		return ctx.Err()
	case err := <-eventChan:
		return err
	}
}
// waitForPodReady waits for the provided pod name relative to this tunnels
// namespace to become fully ready in the pod conditions. This func will block
// until the pod is ready of the context dead line has fired.
waitForPodReady waits for the provided pod name relative to this tunnels
namespace to become fully ready in the pod conditions. This func will block
until the pod is ready of the context dead line has fired.
// waitForPodReady waits for the provided pod name relative to this tunnels // namespace to become fully ready in the pod conditions . This func will block // until the pod is ready of the context dead line has fired .
func (t *Tunnel) waitForPodReady(ctx context.Context, podName string) error {
	clientSet := kubernetes.New(t.client)
	factory := informers.NewSharedInformerFactoryWithOptions(
		clientSet,
		time.Minute,
		informers.WithNamespace(t.Namespace),
	)
	informer := factory.Core().V1().Pods().Informer()
	stopChan := make(chan struct{})
	eventChan := make(chan error)
	defer close(stopChan)
	defer close(eventChan)
	informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc: func(obj interface{}) {
			objPod, valid := obj.(*corev1.Pod)
			if !valid {
				eventChan <- errors.New("expected valid pod for informer")
				return
			}
			if objPod.Name == podName && pod.IsPodRunning(objPod) {
				eventChan <- nil
			}
		},
		UpdateFunc: func(oldObj, newObj interface{}) {
			objPod, valid := newObj.(*corev1.Pod)
			if !valid {
				eventChan <- errors.New("expected valid pod for informer")
				return
			}
			if objPod.Name == podName && pod.IsPodRunning(objPod) {
				eventChan <- nil
			}
		},
		DeleteFunc: func(obj interface{}) {
			pod, valid := obj.(*corev1.Pod)
			if !valid {
				eventChan <- errors.New("expected valid pod for informer")
				return
			}
			if pod.Name == podName {
				eventChan <- errors.Errorf("tunnel pod %s is being deleted", podName)
			}
		},
	})
	go informer.Run(stopChan)
	select {
	case <-ctx.Done():
		return ctx.Err()
	case err := <-eventChan:
		return err
	}
}
func ( t * Tunnel ) waitForPodReady ( ctx context . Context , podName string ) error { clientSet := kubernetes . New ( t . client ) factory := informers . NewSharedInformerFactoryWithOptions ( clientSet , time . Minute , informers . WithNamespace ( t . Namespace ) , ) informer := factory . Core ( ) . V1 ( ) . Pods ( ) . Informer ( ) stopChan := make ( chan struct { } ) eventChan := make ( chan error ) defer close ( stopChan ) defer close ( eventChan ) informer . AddEventHandler ( cache . ResourceEventHandlerFuncs { AddFunc : func ( obj interface { } ) { objPod , valid := obj . ( * corev1 . Pod ) if ! valid { eventChan <- errors . New ( " " ) return } if objPod . Name == podName && pod . IsPodRunning ( objPod ) { eventChan <- nil } } , UpdateFunc : func ( oldObj , newObj interface { } ) { objPod , valid := newObj . ( * corev1 . Pod ) if ! valid { eventChan <- errors . New ( " " ) return } if objPod . Name == podName && pod . IsPodRunning ( objPod ) { eventChan <- nil } } , DeleteFunc : func ( obj interface { } ) { pod , valid := obj . ( * corev1 . Pod ) if ! valid { eventChan <- errors . New ( " " ) return } if pod . Name == podName { eventChan <- errors . Errorf ( " " , podName ) } } , } ) go informer . Run ( stopChan ) select { case <- ctx . Done ( ) : return ctx . Err ( ) case err := <- eventChan : return err } }
waitForPodReady waits for the provided pod name relative to this tunnels
namespace to become fully ready in the pod conditions.
waitForPodReady waits for the provided pod name relative to this tunnels namespace to become fully ready in the pod conditions .