From 144c6b454aa8799d7b7a41c1b442d4f773b5f8fd Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 9 Dec 2024 16:04:52 +0100 Subject: [PATCH] client-go informers: provide ListWatch *WithContext variants For compatibility reasons, the old functions without the ctx parameter still get generated, now with context.Background instead of context.TODO. In practice that code won't be used by the client-go reflector code because it prefers the *WithContext functions, but it cannot be ruled out that some other code only supports the old fields. Kubernetes-commit: 8cc74e8a266e1042be1c60adfa3091852036f48a --- .../samplecontroller/v1alpha1/foo.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go b/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go index 3d3ce74b..b3f20c8c 100644 --- a/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go +++ b/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go @@ -62,13 +62,25 @@ func NewFilteredFooInformer(client versioned.Interface, namespace string, resync if tweakListOptions != nil { tweakListOptions(&options) } - return client.SamplecontrollerV1alpha1().Foos(namespace).List(context.TODO(), options) + return client.SamplecontrollerV1alpha1().Foos(namespace).List(context.Background(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(context.TODO(), options) + return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(context.Background(), options) + }, + ListWithContextFunc: func(ctx context.Context, options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SamplecontrollerV1alpha1().Foos(namespace).List(ctx, options) + }, + WatchFuncWithContext: func(ctx context.Context, options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(ctx, options) }, }, &apissamplecontrollerv1alpha1.Foo{},