@@ -740,6 +740,10 @@ func (k *K8s) EventsSecrets(channel chan SyncDataEvent, stop chan struct{}, info
740740}
741741
742742func (k * K8s ) EventPods (namespace , podPrefix string , resyncPeriod time.Duration , eventChan chan SyncDataEvent ) {
743+ var prefix string
744+ if podPrefix == "" {
745+ return
746+ }
743747 watchlist := cache .NewListWatchFromClient (k .API .CoreV1 ().RESTClient (), "pods" , namespace , fields .Nothing ())
744748 _ , eController := cache .NewInformer (
745749 watchlist ,
@@ -748,15 +752,16 @@ func (k *K8s) EventPods(namespace, podPrefix string, resyncPeriod time.Duration,
748752 cache.ResourceEventHandlerFuncs {
749753 AddFunc : func (obj interface {}) {
750754 meta := obj .(* corev1.Pod ).ObjectMeta
751- if utils .GetPodPrefix (meta .Name ) != podPrefix {
755+ prefix , _ = utils .GetPodPrefix (meta .Name )
756+ if prefix != podPrefix {
752757 return
753758 }
754759 eventChan <- SyncDataEvent {SyncType : POD , Namespace : meta .Namespace , Data : store.PodEvent {Created : true }}
755760 },
756761 DeleteFunc : func (obj interface {}) {
757762 meta := obj .(* corev1.Pod ).ObjectMeta
758-
759- if utils . GetPodPrefix ( meta . Name ) != podPrefix {
763+ prefix , _ = utils . GetPodPrefix ( meta . Name )
764+ if prefix != podPrefix {
760765 return
761766 }
762767 eventChan <- SyncDataEvent {SyncType : POD , Namespace : meta .Namespace , Data : store.PodEvent {}}
0 commit comments