@@ -124,7 +124,7 @@ var _ = Describe("Informer Cache", func() {
124
124
It ("should be able to list objects that haven't been watched previously" , func () {
125
125
By ("listing all services in the cluster" )
126
126
listObj := & kcorev1.ServiceList {}
127
- Expect (informerCache .List (context .Background (), nil , listObj )).To (Succeed ())
127
+ Expect (informerCache .List (context .Background (), listObj )).To (Succeed ())
128
128
129
129
By ("verifying that the returned list contains the Kubernetes service" )
130
130
// NB: kubernetes default service is automatically created in testenv.
@@ -154,10 +154,9 @@ var _ = Describe("Informer Cache", func() {
154
154
By ("listing pods with a particular label" )
155
155
// NB: each pod has a "test-label": <pod-name>
156
156
out := kcorev1.PodList {}
157
- lo := & client.ListOptions {}
158
- lo .InNamespace (testNamespaceTwo )
159
- lo .MatchingLabels (map [string ]string {"test-label" : "test-pod-2" })
160
- Expect (informerCache .List (context .Background (), lo , & out )).To (Succeed ())
157
+ Expect (informerCache .List (context .Background (), & out ,
158
+ client .InNamespace (testNamespaceTwo ),
159
+ client .MatchingLabels (map [string ]string {"test-label" : "test-pod-2" }))).To (Succeed ())
161
160
162
161
By ("verifying the returned pods have the correct label" )
163
162
Expect (out .Items ).NotTo (BeEmpty ())
@@ -174,9 +173,7 @@ var _ = Describe("Informer Cache", func() {
174
173
// NB: each pod has a "test-label": <pod-name>
175
174
out := kcorev1.PodList {}
176
175
labels := map [string ]string {"test-label" : "test-pod-2" }
177
- lo := & client.ListOptions {}
178
- lo .MatchingLabels (labels )
179
- Expect (informerCache .List (context .Background (), lo , & out )).To (Succeed ())
176
+ Expect (informerCache .List (context .Background (), & out , client .MatchingLabels (labels ))).To (Succeed ())
180
177
181
178
By ("verifying multiple pods with the same label in different namespaces are returned" )
182
179
Expect (out .Items ).NotTo (BeEmpty ())
@@ -191,9 +188,8 @@ var _ = Describe("Informer Cache", func() {
191
188
It ("should be able to list objects by namespace" , func () {
192
189
By ("listing pods in test-namespace-1" )
193
190
listObj := & kcorev1.PodList {}
194
- lo := & client.ListOptions {}
195
- lo .InNamespace (testNamespaceOne )
196
- Expect (informerCache .List (context .Background (), lo , listObj )).To (Succeed ())
191
+ Expect (informerCache .List (context .Background (), listObj ,
192
+ client .InNamespace (testNamespaceOne ))).To (Succeed ())
197
193
198
194
By ("verifying that the returned pods are in test-namespace-1" )
199
195
Expect (listObj .Items ).NotTo (BeEmpty ())
@@ -216,7 +212,7 @@ var _ = Describe("Informer Cache", func() {
216
212
217
213
By ("listing pods in all namespaces" )
218
214
out := & kcorev1.PodList {}
219
- Expect (namespacedCache .List (context .Background (), nil , out )).To (Succeed ())
215
+ Expect (namespacedCache .List (context .Background (), out )).To (Succeed ())
220
216
221
217
By ("verifying the returned pod is from the watched namespace" )
222
218
Expect (out .Items ).NotTo (BeEmpty ())
@@ -225,7 +221,7 @@ var _ = Describe("Informer Cache", func() {
225
221
226
222
By ("listing all namespaces - should still be able to get a cluster-scoped resource" )
227
223
namespaceList := & kcorev1.NamespaceList {}
228
- Expect (namespacedCache .List (context .Background (), nil , namespaceList )).To (Succeed ())
224
+ Expect (namespacedCache .List (context .Background (), namespaceList )).To (Succeed ())
229
225
230
226
By ("verifying the namespace list is not empty" )
231
227
Expect (namespaceList .Items ).NotTo (BeEmpty ())
@@ -267,7 +263,7 @@ var _ = Describe("Informer Cache", func() {
267
263
Version : "v1" ,
268
264
Kind : "ServiceList" ,
269
265
})
270
- err := informerCache .List (context .Background (), nil , listObj )
266
+ err := informerCache .List (context .Background (), listObj )
271
267
Expect (err ).To (Succeed ())
272
268
273
269
By ("verifying that the returned list contains the Kubernetes service" )
@@ -308,10 +304,9 @@ var _ = Describe("Informer Cache", func() {
308
304
Version : "v1" ,
309
305
Kind : "PodList" ,
310
306
})
311
- lo := & client.ListOptions {}
312
- lo .InNamespace (testNamespaceTwo )
313
- lo .MatchingLabels (map [string ]string {"test-label" : "test-pod-2" })
314
- err := informerCache .List (context .Background (), lo , & out )
307
+ err := informerCache .List (context .Background (), & out ,
308
+ client .InNamespace (testNamespaceTwo ),
309
+ client .MatchingLabels (map [string ]string {"test-label" : "test-pod-2" }))
315
310
Expect (err ).To (Succeed ())
316
311
317
312
By ("verifying the returned pods have the correct label" )
@@ -334,9 +329,7 @@ var _ = Describe("Informer Cache", func() {
334
329
Kind : "PodList" ,
335
330
})
336
331
labels := map [string ]string {"test-label" : "test-pod-2" }
337
- lo := & client.ListOptions {}
338
- lo .MatchingLabels (labels )
339
- err := informerCache .List (context .Background (), lo , & out )
332
+ err := informerCache .List (context .Background (), & out , client .MatchingLabels (labels ))
340
333
Expect (err ).To (Succeed ())
341
334
342
335
By ("verifying multiple pods with the same label in different namespaces are returned" )
@@ -357,9 +350,7 @@ var _ = Describe("Informer Cache", func() {
357
350
Version : "v1" ,
358
351
Kind : "PodList" ,
359
352
})
360
- lo := & client.ListOptions {}
361
- lo .InNamespace (testNamespaceOne )
362
- err := informerCache .List (context .Background (), lo , listObj )
353
+ err := informerCache .List (context .Background (), listObj , client .InNamespace (testNamespaceOne ))
363
354
Expect (err ).To (Succeed ())
364
355
365
356
By ("verifying that the returned pods are in test-namespace-1" )
@@ -388,7 +379,7 @@ var _ = Describe("Informer Cache", func() {
388
379
Version : "v1" ,
389
380
Kind : "PodList" ,
390
381
})
391
- Expect (namespacedCache .List (context .Background (), nil , out )).To (Succeed ())
382
+ Expect (namespacedCache .List (context .Background (), out )).To (Succeed ())
392
383
393
384
By ("verifying the returned pod is from the watched namespace" )
394
385
Expect (out .Items ).NotTo (BeEmpty ())
@@ -402,7 +393,7 @@ var _ = Describe("Informer Cache", func() {
402
393
Version : "v1" ,
403
394
Kind : "NamespaceList" ,
404
395
})
405
- Expect (namespacedCache .List (context .Background (), nil , namespaceList )).To (Succeed ())
396
+ Expect (namespacedCache .List (context .Background (), namespaceList )).To (Succeed ())
406
397
407
398
By ("verifying the namespace list is not empty" )
408
399
Expect (namespaceList .Items ).NotTo (BeEmpty ())
@@ -552,9 +543,8 @@ var _ = Describe("Informer Cache", func() {
552
543
553
544
By ("listing Pods with restartPolicyOnFailure" )
554
545
listObj := & kcorev1.PodList {}
555
- lo := & client.ListOptions {}
556
- lo .MatchingField ("spec.restartPolicy" , "OnFailure" )
557
- Expect (informer .List (context .Background (), lo , listObj )).To (Succeed ())
546
+ Expect (informer .List (context .Background (), listObj ,
547
+ client .MatchingField ("spec.restartPolicy" , "OnFailure" ))).To (Succeed ())
558
548
559
549
By ("verifying that the returned pods have correct restart policy" )
560
550
Expect (listObj .Items ).NotTo (BeEmpty ())
@@ -647,9 +637,8 @@ var _ = Describe("Informer Cache", func() {
647
637
Version : "v1" ,
648
638
Kind : "PodList" ,
649
639
})
650
- lo := & client.ListOptions {}
651
- lo .MatchingField ("spec.restartPolicy" , "OnFailure" )
652
- err = informer .List (context .Background (), lo , listObj )
640
+ err = informer .List (context .Background (), listObj ,
641
+ client .MatchingField ("spec.restartPolicy" , "OnFailure" ))
653
642
Expect (err ).To (Succeed ())
654
643
655
644
By ("verifying that the returned pods have correct restart policy" )
0 commit comments