diff --git a/src/k8s/pkg/utils/k8s/configmap.go b/src/k8s/pkg/utils/k8s/configmap.go index 4ad32b3a8..5afe85d4b 100644 --- a/src/k8s/pkg/utils/k8s/configmap.go +++ b/src/k8s/pkg/utils/k8s/configmap.go @@ -20,16 +20,17 @@ func (c *Client) WatchConfigMap(ctx context.Context, namespace string, name stri select { case <-ctx.Done(): return nil - case evt := <-w.ResultChan(): - if evt.Object != nil { - configMap, ok := evt.Object.(*v1.ConfigMap) - if !ok { - return fmt.Errorf("expected a ConfigMap but received %#v", evt.Object) - } + case evt, ok := <-w.ResultChan(): + if !ok { + return fmt.Errorf("watch closed") + } + configMap, ok := evt.Object.(*v1.ConfigMap) + if !ok { + return fmt.Errorf("expected a ConfigMap but received %#v", evt.Object) + } - if err := reconcile(configMap); err != nil { - log.Println(fmt.Errorf("failed to reconcile configmap, namespace: %s name: %s: %w", namespace, name, err)) - } + if err := reconcile(configMap); err != nil { + log.Println(fmt.Errorf("failed to reconcile configmap, namespace: %s name: %s: %w", namespace, name, err)) } } }