update dependencies (#6267)
Signed-off-by: hongming <coder.scala@gmail.com>
This commit is contained in:
68
vendor/sigs.k8s.io/controller-runtime/pkg/handler/enqueue_mapped.go
generated
vendored
68
vendor/sigs.k8s.io/controller-runtime/pkg/handler/enqueue_mapped.go
generated
vendored
@@ -27,7 +27,13 @@ import (
|
||||
|
||||
// MapFunc is the signature required for enqueueing requests from a generic function.
|
||||
// This type is usually used with EnqueueRequestsFromMapFunc when registering an event handler.
|
||||
type MapFunc func(context.Context, client.Object) []reconcile.Request
|
||||
type MapFunc = TypedMapFunc[client.Object, reconcile.Request]
|
||||
|
||||
// TypedMapFunc is the signature required for enqueueing requests from a generic function.
|
||||
// This type is usually used with EnqueueRequestsFromTypedMapFunc when registering an event handler.
|
||||
//
|
||||
// TypedMapFunc is experimental and subject to future change.
|
||||
type TypedMapFunc[object any, request comparable] func(context.Context, object) []request
|
||||
|
||||
// EnqueueRequestsFromMapFunc enqueues Requests by running a transformation function that outputs a collection
|
||||
// of reconcile.Requests on each Event. The reconcile.Requests may be for an arbitrary set of objects
|
||||
@@ -40,45 +46,77 @@ type MapFunc func(context.Context, client.Object) []reconcile.Request
|
||||
// For UpdateEvents which contain both a new and old object, the transformation function is run on both
|
||||
// objects and both sets of Requests are enqueue.
|
||||
func EnqueueRequestsFromMapFunc(fn MapFunc) EventHandler {
|
||||
return &enqueueRequestsFromMapFunc{
|
||||
return TypedEnqueueRequestsFromMapFunc(fn)
|
||||
}
|
||||
|
||||
// TypedEnqueueRequestsFromMapFunc enqueues Requests by running a transformation function that outputs a collection
|
||||
// of reconcile.Requests on each Event. The reconcile.Requests may be for an arbitrary set of objects
|
||||
// defined by some user specified transformation of the source Event. (e.g. trigger Reconciler for a set of objects
|
||||
// in response to a cluster resize event caused by adding or deleting a Node)
|
||||
//
|
||||
// TypedEnqueueRequestsFromMapFunc is frequently used to fan-out updates from one object to one or more other
|
||||
// objects of a differing type.
|
||||
//
|
||||
// For TypedUpdateEvents which contain both a new and old object, the transformation function is run on both
|
||||
// objects and both sets of Requests are enqueue.
|
||||
//
|
||||
// TypedEnqueueRequestsFromMapFunc is experimental and subject to future change.
|
||||
func TypedEnqueueRequestsFromMapFunc[object any, request comparable](fn TypedMapFunc[object, request]) TypedEventHandler[object, request] {
|
||||
return &enqueueRequestsFromMapFunc[object, request]{
|
||||
toRequests: fn,
|
||||
}
|
||||
}
|
||||
|
||||
var _ EventHandler = &enqueueRequestsFromMapFunc{}
|
||||
var _ EventHandler = &enqueueRequestsFromMapFunc[client.Object, reconcile.Request]{}
|
||||
|
||||
type enqueueRequestsFromMapFunc struct {
|
||||
type enqueueRequestsFromMapFunc[object any, request comparable] struct {
|
||||
// Mapper transforms the argument into a slice of keys to be reconciled
|
||||
toRequests MapFunc
|
||||
toRequests TypedMapFunc[object, request]
|
||||
}
|
||||
|
||||
// Create implements EventHandler.
|
||||
func (e *enqueueRequestsFromMapFunc) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) {
|
||||
reqs := map[reconcile.Request]empty{}
|
||||
func (e *enqueueRequestsFromMapFunc[object, request]) Create(
|
||||
ctx context.Context,
|
||||
evt event.TypedCreateEvent[object],
|
||||
q workqueue.TypedRateLimitingInterface[request],
|
||||
) {
|
||||
reqs := map[request]empty{}
|
||||
e.mapAndEnqueue(ctx, q, evt.Object, reqs)
|
||||
}
|
||||
|
||||
// Update implements EventHandler.
|
||||
func (e *enqueueRequestsFromMapFunc) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) {
|
||||
reqs := map[reconcile.Request]empty{}
|
||||
func (e *enqueueRequestsFromMapFunc[object, request]) Update(
|
||||
ctx context.Context,
|
||||
evt event.TypedUpdateEvent[object],
|
||||
q workqueue.TypedRateLimitingInterface[request],
|
||||
) {
|
||||
reqs := map[request]empty{}
|
||||
e.mapAndEnqueue(ctx, q, evt.ObjectOld, reqs)
|
||||
e.mapAndEnqueue(ctx, q, evt.ObjectNew, reqs)
|
||||
}
|
||||
|
||||
// Delete implements EventHandler.
|
||||
func (e *enqueueRequestsFromMapFunc) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) {
|
||||
reqs := map[reconcile.Request]empty{}
|
||||
func (e *enqueueRequestsFromMapFunc[object, request]) Delete(
|
||||
ctx context.Context,
|
||||
evt event.TypedDeleteEvent[object],
|
||||
q workqueue.TypedRateLimitingInterface[request],
|
||||
) {
|
||||
reqs := map[request]empty{}
|
||||
e.mapAndEnqueue(ctx, q, evt.Object, reqs)
|
||||
}
|
||||
|
||||
// Generic implements EventHandler.
|
||||
func (e *enqueueRequestsFromMapFunc) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) {
|
||||
reqs := map[reconcile.Request]empty{}
|
||||
func (e *enqueueRequestsFromMapFunc[object, request]) Generic(
|
||||
ctx context.Context,
|
||||
evt event.TypedGenericEvent[object],
|
||||
q workqueue.TypedRateLimitingInterface[request],
|
||||
) {
|
||||
reqs := map[request]empty{}
|
||||
e.mapAndEnqueue(ctx, q, evt.Object, reqs)
|
||||
}
|
||||
|
||||
func (e *enqueueRequestsFromMapFunc) mapAndEnqueue(ctx context.Context, q workqueue.RateLimitingInterface, object client.Object, reqs map[reconcile.Request]empty) {
|
||||
for _, req := range e.toRequests(ctx, object) {
|
||||
func (e *enqueueRequestsFromMapFunc[object, request]) mapAndEnqueue(ctx context.Context, q workqueue.TypedRateLimitingInterface[request], o object, reqs map[request]empty) {
|
||||
for _, req := range e.toRequests(ctx, o) {
|
||||
_, ok := reqs[req]
|
||||
if !ok {
|
||||
q.Add(req)
|
||||
|
||||
Reference in New Issue
Block a user