Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add missing generic version of ResourceVersionChangedPredicate #2812

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions pkg/predicate/predicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,21 @@
}
}

// ResourceVersionChangedPredicate implements a default update predicate function on resource version change.
type ResourceVersionChangedPredicate struct {
Funcs
// GenerationChangedPredicate implements a default update predicate function on resource version change.

Check failure on line 148 in pkg/predicate/predicate.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported type ResourceVersionChangedPredicate should be of the form "ResourceVersionChangedPredicate ..." (with optional leading article) (revive)

Check warning on line 148 in pkg/predicate/predicate.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported type ResourceVersionChangedPredicate should be of the form "ResourceVersionChangedPredicate ..." (with optional leading article) (revive)
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
}
Expand Down