Use the generic/typed workqueue throughout

This change makes us use the generic workqueue throughout the project in
order to improve type safety and readability of the code.
This commit is contained in:
Alvaro Aleman
2024-04-28 18:26:18 +02:00
parent d387c0c903
commit 6d0ac8c561
94 changed files with 830 additions and 603 deletions

View File

@@ -61,7 +61,7 @@ type Controller struct {
// queue is where incoming work is placed to de-dup and to allow "easy" rate limited requeues on errors.
// we only ever place one entry in here, but it is keyed as usual: namespace/name
queue workqueue.RateLimitingInterface
queue workqueue.TypedRateLimitingInterface[string]
// kubeSystemConfigMapInformer is tracked so that we can start these on Run
kubeSystemConfigMapInformer cache.SharedIndexInformer
@@ -94,11 +94,14 @@ func NewClusterAuthenticationTrustController(requiredAuthenticationData ClusterA
kubeSystemConfigMapInformer := corev1informers.NewConfigMapInformer(kubeClient, configMapNamespace, 12*time.Hour, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
c := &Controller{
requiredAuthenticationData: requiredAuthenticationData,
configMapLister: corev1listers.NewConfigMapLister(kubeSystemConfigMapInformer.GetIndexer()),
configMapClient: kubeClient.CoreV1(),
namespaceClient: kubeClient.CoreV1(),
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "cluster_authentication_trust_controller"),
requiredAuthenticationData: requiredAuthenticationData,
configMapLister: corev1listers.NewConfigMapLister(kubeSystemConfigMapInformer.GetIndexer()),
configMapClient: kubeClient.CoreV1(),
namespaceClient: kubeClient.CoreV1(),
queue: workqueue.NewTypedRateLimitingQueueWithConfig(
workqueue.DefaultTypedControllerRateLimiter[string](),
workqueue.TypedRateLimitingQueueConfig[string]{Name: "cluster_authentication_trust_controller"},
),
preRunCaches: []cache.InformerSynced{kubeSystemConfigMapInformer.HasSynced},
kubeSystemConfigMapInformer: kubeSystemConfigMapInformer,
}