From d8419d11f0b453ec426ed7596a3c28a16dd499c2 Mon Sep 17 00:00:00 2001 From: Puran Adhikari <7930721+PuranAdhikari@users.noreply.github.com> Date: Mon, 20 Mar 2023 19:19:54 +0545 Subject: [PATCH] fix(): added a function to add project name in recorder (#19) Signed-off-by: Puran Adhikari --- pkg/events/events.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/events/events.go b/pkg/events/events.go index 47b63ae..1fdafd6 100644 --- a/pkg/events/events.go +++ b/pkg/events/events.go @@ -40,6 +40,8 @@ type EventRecorder interface { WithSlice(string) EventRecorder // WithNamespace returns a new recorder with namespace name added WithNamespace(string) EventRecorder + // WithProject returns a new recorder with project name added + WithProject(string) EventRecorder } func NewEventRecorder(c client.Writer, s *runtime.Scheme, o EventRecorderOptions) EventRecorder { @@ -116,6 +118,13 @@ func (er *eventRecorder) WithNamespace(ns string) EventRecorder { return e } +// WithProject returns a new recorder with added project name +func (er *eventRecorder) WithProject(project string) EventRecorder { + e := er.Copy() + e.Options.Project = project + return e +} + // RecordEvent raises a new event with the given fields // TODO: events caching and aggregation func (er *eventRecorder) RecordEvent(ctx context.Context, e *Event) error {