From a2e9eb74bc3d7f180fdda837408b4ee5841cd807 Mon Sep 17 00:00:00 2001 From: Tim Ramlot <42113979+inteon@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:47:32 +0200 Subject: [PATCH] add missing generic version of ResourceVersionChangedPredicate Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com> --- pkg/predicate/predicate.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/predicate/predicate.go b/pkg/predicate/predicate.go index 38a912a767..90918db57a 100644 --- a/pkg/predicate/predicate.go +++ b/pkg/predicate/predicate.go @@ -146,17 +146,20 @@ func NewTypedPredicateFuncs[object any](filter func(object object) bool) TypedFu } // ResourceVersionChangedPredicate implements a default update predicate function on resource version change. -type ResourceVersionChangedPredicate struct { - Funcs +type ResourceVersionChangedPredicate = TypedResourceVersionChangedPredicate[client.Object] + +// TypedResourceVersionChangedPredicate implements a default update predicate function on resource version change. +type TypedResourceVersionChangedPredicate[T metav1.Object] struct { + TypedFuncs[T] } // Update implements default UpdateEvent filter for validating resource version change. -func (ResourceVersionChangedPredicate) Update(e event.UpdateEvent) bool { - if e.ObjectOld == nil { +func (TypedResourceVersionChangedPredicate[T]) Update(e event.TypedUpdateEvent[T]) bool { + if isNil(e.ObjectOld) { log.Error(nil, "Update event has no old object to update", "event", e) return false } - if e.ObjectNew == nil { + if isNil(e.ObjectNew) { log.Error(nil, "Update event has no new object to update", "event", e) return false }