Skip to content

Commit

Permalink
fix cooldownqueue key from event
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
  • Loading branch information
matthyx committed Sep 17, 2024
1 parent c931614 commit 40b068b
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions utils/cooldownqueue.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 40b068b

Please sign in to comment.