-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(controller): add
IgnoreDelete
predicate (#3003)
Signed-off-by: Hidde Beydals <[email protected]>
- Loading branch information
Showing
5 changed files
with
28 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package predicate | ||
|
||
import ( | ||
"sigs.k8s.io/controller-runtime/pkg/event" | ||
"sigs.k8s.io/controller-runtime/pkg/predicate" | ||
) | ||
|
||
// IgnoreDelete is a predicate that filters out Delete events. | ||
// | ||
// Typically, a reconciler will not need to do anything when it receives an | ||
// event.TypedDeleteEvent, as it acts on the event.TypedUpdateEvent which sets | ||
// the deletion timestamp. | ||
type IgnoreDelete[T any] struct { | ||
predicate.TypedFuncs[T] | ||
} | ||
|
||
// Delete always returns false, ignoring the event. | ||
func (i IgnoreDelete[T]) Delete(event.TypedDeleteEvent[T]) bool { | ||
return false | ||
} |