1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-15 17:51:20 +00:00
kyverno/pkg/event/recorder.go
Mariam Fahmy a60dc00392
feat: migrate to events.k8s.io/v1 (#7673)
* feat: migrate events to events.k8s.io group

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>

* fix: kuttl event tests

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>

* migrate background events to events.k8s.io

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>

* update kuttl tests

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>

* remove ResourceSkipped from actions

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>

---------

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
2023-07-26 14:06:51 +00:00

21 lines
676 B
Go

package event
import (
"github.com/kyverno/kyverno/pkg/client/clientset/versioned/scheme"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
typedeventsv1 "k8s.io/client-go/kubernetes/typed/events/v1"
"k8s.io/client-go/tools/events"
)
func NewRecorder(source Source, sink typedeventsv1.EventsV1Interface) events.EventRecorder {
utilruntime.Must(scheme.AddToScheme(scheme.Scheme))
eventBroadcaster := events.NewBroadcaster(
&events.EventSinkImpl{
Interface: sink,
},
)
eventBroadcaster.StartStructuredLogging(0)
stopCh := make(chan struct{})
eventBroadcaster.StartRecordingToSink(stopCh)
return eventBroadcaster.NewRecorder(scheme.Scheme, string(source))
}