From 73465eed9037fdcdd263d4bb55f0739bc4b3933c Mon Sep 17 00:00:00 2001 From: Katyanna Moura Date: Thu, 19 Oct 2023 12:38:17 +0200 Subject: [PATCH] Check error returned from client-go/SharedInformer.AddEventHandler Fix lint error: Error: kubernetes/pods.go:53:26: Error return value of `informer.AddEventHandler` is not checked (errcheck) Signed-off-by: Katyanna Moura --- kubernetes/pods.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kubernetes/pods.go b/kubernetes/pods.go index b358b4b1..94f673b8 100644 --- a/kubernetes/pods.go +++ b/kubernetes/pods.go @@ -50,7 +50,7 @@ func (a *Adapter) PodInformer(ctx context.Context, endpointChan chan<- []string) queueEndpoints(&podEndpoints, endpointChan) // delta triggered updates - informer.AddEventHandler(cache.ResourceEventHandlerFuncs{ + _, err = informer.AddEventHandler(cache.ResourceEventHandlerFuncs{ UpdateFunc: func(_, newResource interface{}) { pod, ok := newResource.(*corev1.Pod) if !ok { @@ -76,6 +76,9 @@ func (a *Adapter) PodInformer(ctx context.Context, endpointChan chan<- []string) } }, }) + if err != nil { + return err + } <-ctx.Done() return nil }