Skip to content

Commit 8cc74e8

Browse files
committed
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.
1 parent 6688ada commit 8cc74e8

File tree

154 files changed

+2146
-308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+2146
-308
lines changed

staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/informers/externalversions/cr/v1/example.go

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1/customresourcedefinition.go

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions/apiextensions/v1beta1/customresourcedefinition.go

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/client-go/dynamic/dynamicinformer/informer.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,25 @@ func NewFilteredDynamicInformer(client dynamic.Interface, gvr schema.GroupVersio
153153
if tweakListOptions != nil {
154154
tweakListOptions(&options)
155155
}
156-
return client.Resource(gvr).Namespace(namespace).List(context.TODO(), options)
156+
return client.Resource(gvr).Namespace(namespace).List(context.Background(), options)
157157
},
158158
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
159159
if tweakListOptions != nil {
160160
tweakListOptions(&options)
161161
}
162-
return client.Resource(gvr).Namespace(namespace).Watch(context.TODO(), options)
162+
return client.Resource(gvr).Namespace(namespace).Watch(context.Background(), options)
163+
},
164+
ListWithContextFunc: func(ctx context.Context, options metav1.ListOptions) (runtime.Object, error) {
165+
if tweakListOptions != nil {
166+
tweakListOptions(&options)
167+
}
168+
return client.Resource(gvr).Namespace(namespace).List(ctx, options)
169+
},
170+
WatchFuncWithContext: func(ctx context.Context, options metav1.ListOptions) (watch.Interface, error) {
171+
if tweakListOptions != nil {
172+
tweakListOptions(&options)
173+
}
174+
return client.Resource(gvr).Namespace(namespace).Watch(ctx, options)
163175
},
164176
},
165177
&unstructured.Unstructured{},

staging/src/k8s.io/client-go/informers/admissionregistration/v1/mutatingwebhookconfiguration.go

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/client-go/informers/admissionregistration/v1/validatingadmissionpolicy.go

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/client-go/informers/admissionregistration/v1/validatingadmissionpolicybinding.go

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/client-go/informers/admissionregistration/v1/validatingwebhookconfiguration.go

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/client-go/informers/admissionregistration/v1alpha1/mutatingadmissionpolicy.go

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/client-go/informers/admissionregistration/v1alpha1/mutatingadmissionpolicybinding.go

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)