@@ -245,20 +245,23 @@ func createStructuredListWatch(gvk schema.GroupVersionKind, ip *specificInformer
245
245
return nil , err
246
246
}
247
247
248
+ // TODO: the functions that make use of this ListWatch should be adapted to
249
+ // pass in their own contexts instead of relying on this fixed one here.
250
+ ctx := context .TODO ()
248
251
// Create a new ListWatch for the obj
249
252
return & cache.ListWatch {
250
253
ListFunc : func (opts metav1.ListOptions ) (runtime.Object , error ) {
251
254
res := listObj .DeepCopyObject ()
252
255
isNamespaceScoped := ip .namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot
253
- err := client .Get ().NamespaceIfScoped (ip .namespace , isNamespaceScoped ).Resource (mapping .Resource .Resource ).VersionedParams (& opts , ip .paramCodec ).Do ().Into (res )
256
+ err := client .Get ().NamespaceIfScoped (ip .namespace , isNamespaceScoped ).Resource (mapping .Resource .Resource ).VersionedParams (& opts , ip .paramCodec ).Do (ctx ).Into (res )
254
257
return res , err
255
258
},
256
259
// Setup the watch function
257
260
WatchFunc : func (opts metav1.ListOptions ) (watch.Interface , error ) {
258
261
// Watch needs to be set to true separately
259
262
opts .Watch = true
260
263
isNamespaceScoped := ip .namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot
261
- return client .Get ().NamespaceIfScoped (ip .namespace , isNamespaceScoped ).Resource (mapping .Resource .Resource ).VersionedParams (& opts , ip .paramCodec ).Watch ()
264
+ return client .Get ().NamespaceIfScoped (ip .namespace , isNamespaceScoped ).Resource (mapping .Resource .Resource ).VersionedParams (& opts , ip .paramCodec ).Watch (ctx )
262
265
},
263
266
}, nil
264
267
}
@@ -275,22 +278,25 @@ func createUnstructuredListWatch(gvk schema.GroupVersionKind, ip *specificInform
275
278
return nil , err
276
279
}
277
280
281
+ // TODO: the functions that make use of this ListWatch should be adapted to
282
+ // pass in their own contexts instead of relying on this fixed one here.
283
+ ctx := context .TODO ()
278
284
// Create a new ListWatch for the obj
279
285
return & cache.ListWatch {
280
286
ListFunc : func (opts metav1.ListOptions ) (runtime.Object , error ) {
281
287
if ip .namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot {
282
- return dynamicClient .Resource (mapping .Resource ).Namespace (ip .namespace ).List (opts )
288
+ return dynamicClient .Resource (mapping .Resource ).Namespace (ip .namespace ).List (ctx , opts )
283
289
}
284
- return dynamicClient .Resource (mapping .Resource ).List (opts )
290
+ return dynamicClient .Resource (mapping .Resource ).List (ctx , opts )
285
291
},
286
292
// Setup the watch function
287
293
WatchFunc : func (opts metav1.ListOptions ) (watch.Interface , error ) {
288
294
// Watch needs to be set to true separately
289
295
opts .Watch = true
290
296
if ip .namespace != "" && mapping .Scope .Name () != meta .RESTScopeNameRoot {
291
- return dynamicClient .Resource (mapping .Resource ).Namespace (ip .namespace ).Watch (opts )
297
+ return dynamicClient .Resource (mapping .Resource ).Namespace (ip .namespace ).Watch (ctx , opts )
292
298
}
293
- return dynamicClient .Resource (mapping .Resource ).Watch (opts )
299
+ return dynamicClient .Resource (mapping .Resource ).Watch (ctx , opts )
294
300
},
295
301
}, nil
296
302
}
0 commit comments