From b89e4908dae57717094dfe415c2af666f9225537 Mon Sep 17 00:00:00 2001 From: Andreas Gkizas Date: Fri, 12 Jan 2024 11:04:16 +0200 Subject: [PATCH] checks for namespace and node --- kubernetes/watcher.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kubernetes/watcher.go b/kubernetes/watcher.go index ebc35606b..b75177987 100644 --- a/kubernetes/watcher.go +++ b/kubernetes/watcher.go @@ -20,8 +20,6 @@ package kubernetes import ( "context" "fmt" - "reflect" - "strings" "time" "k8s.io/apimachinery/pkg/api/meta" @@ -166,11 +164,12 @@ func NewNamedWatcher(name string, client kubernetes.Interface, resource Resource } //We check the type of resource and only if it is namespace or node return the cacheObject - stringresource := reflect.TypeOf(resource).String() - if strings.Contains(strings.ToLower(stringresource), "namespace") || strings.Contains(strings.ToLower(stringresource), "node") { + switch resource.(type) { + case *Namespace: + w.cacheObject(o) + case *Node: w.cacheObject(o) } - }, })