From 40b068b1f234527457e9bd452404046e3e5032a7 Mon Sep 17 00:00:00 2001 From: Matthias Bertschy Date: Tue, 17 Sep 2024 12:45:39 +0200 Subject: [PATCH] fix cooldownqueue key from event Signed-off-by: Matthias Bertschy --- utils/cooldownqueue.go | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/utils/cooldownqueue.go b/utils/cooldownqueue.go index 8d13a0f..4213c58 100644 --- a/utils/cooldownqueue.go +++ b/utils/cooldownqueue.go @@ -1,11 +1,11 @@ package utils import ( + "strings" "time" - "github.com/kubescape/synchronizer/domain" "istio.io/pkg/cache" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" ) @@ -44,20 +44,9 @@ func NewCooldownQueue() *CooldownQueue { // makeEventKey creates a unique key for an event from a watcher func makeEventKey(e watch.Event) string { - object, ok := e.Object.(*unstructured.Unstructured) - if !ok { - return "" - } - id := domain.KindName{ - Kind: &domain.Kind{ - Group: object.GetAPIVersion(), - Resource: object.GetKind(), - }, - Name: object.GetName(), - Namespace: object.GetNamespace(), - } - - return id.String() + gvk := e.Object.GetObjectKind().GroupVersionKind() + meta := e.Object.(metav1.Object) + return strings.Join([]string{gvk.Group, gvk.Version, gvk.Kind, meta.GetNamespace(), meta.GetName()}, "/") } func (q *CooldownQueue) Closed() bool {