1 /* 2 Copyright 2018 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package event 18 19 import "sigs.k8s.io/controller-runtime/pkg/client" 20 21 // CreateEvent is an event where a Kubernetes object was created. CreateEvent should be generated 22 // by a source.Source and transformed into a reconcile.Request by a handler.EventHandler. 23 type CreateEvent = TypedCreateEvent[client.Object] 24 25 // UpdateEvent is an event where a Kubernetes object was updated. UpdateEvent should be generated 26 // by a source.Source and transformed into a reconcile.Request by an handler.EventHandler. 27 type UpdateEvent = TypedUpdateEvent[client.Object] 28 29 // DeleteEvent is an event where a Kubernetes object was deleted. DeleteEvent should be generated 30 // by a source.Source and transformed into a reconcile.Request by an handler.EventHandler. 31 type DeleteEvent = TypedDeleteEvent[client.Object] 32 33 // GenericEvent is an event where the operation type is unknown (e.g. polling or event originating outside the cluster). 34 // GenericEvent should be generated by a source.Source and transformed into a reconcile.Request by an 35 // handler.EventHandler. 36 type GenericEvent = TypedGenericEvent[client.Object] 37 38 // TypedCreateEvent is an event where a Kubernetes object was created. TypedCreateEvent should be generated 39 // by a source.Source and transformed into a reconcile.Request by an handler.TypedEventHandler. 40 type TypedCreateEvent[T any] struct { 41 // Object is the object from the event 42 Object T 43 } 44 45 // TypedUpdateEvent is an event where a Kubernetes object was updated. TypedUpdateEvent should be generated 46 // by a source.Source and transformed into a reconcile.Request by an handler.TypedEventHandler. 47 type TypedUpdateEvent[T any] struct { 48 // ObjectOld is the object from the event 49 ObjectOld T 50 51 // ObjectNew is the object from the event 52 ObjectNew T 53 } 54 55 // TypedDeleteEvent is an event where a Kubernetes object was deleted. TypedDeleteEvent should be generated 56 // by a source.Source and transformed into a reconcile.Request by an handler.TypedEventHandler. 57 type TypedDeleteEvent[T any] struct { 58 // Object is the object from the event 59 Object T 60 61 // DeleteStateUnknown is true if the Delete event was missed but we identified the object 62 // as having been deleted. 63 DeleteStateUnknown bool 64 } 65 66 // TypedGenericEvent is an event where the operation type is unknown (e.g. polling or event originating outside the cluster). 67 // TypedGenericEvent should be generated by a source.Source and transformed into a reconcile.Request by an 68 // handler.TypedEventHandler. 69 type TypedGenericEvent[T any] struct { 70 // Object is the object from the event 71 Object T 72 } 73