Skip to content

Commit

Permalink
Merge pull request #86 from kubescape/fix
Browse files Browse the repository at this point in the history
fix cooldownqueue key from event
  • Loading branch information
matthyx authored Sep 17, 2024
2 parents c931614 + 40b068b commit c2c0b88
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 c2c0b88

Please sign in to comment.