@@ -431,8 +431,9 @@ func (c *Cacher) Delete(ctx context.Context, key string, out runtime.Object, pre
431
431
}
432
432
433
433
// Watch implements storage.Interface.
434
- func (c * Cacher ) Watch (ctx context.Context , key string , resourceVersion string , pred storage.SelectionPredicate ) (watch.Interface , error ) {
435
- watchRV , err := c .versioner .ParseResourceVersion (resourceVersion )
434
+ func (c * Cacher ) Watch (ctx context.Context , key string , opts storage.ListOptions ) (watch.Interface , error ) {
435
+ pred := opts .Predicate
436
+ watchRV , err := c .versioner .ParseResourceVersion (opts .ResourceVersion )
436
437
if err != nil {
437
438
return nil , err
438
439
}
@@ -515,30 +516,30 @@ func (c *Cacher) Watch(ctx context.Context, key string, resourceVersion string,
515
516
}
516
517
517
518
// WatchList implements storage.Interface.
518
- func (c * Cacher ) WatchList (ctx context.Context , key string , resourceVersion string , pred storage.SelectionPredicate ) (watch.Interface , error ) {
519
- return c .Watch (ctx , key , resourceVersion , pred )
519
+ func (c * Cacher ) WatchList (ctx context.Context , key string , opts storage.ListOptions ) (watch.Interface , error ) {
520
+ return c .Watch (ctx , key , opts )
520
521
}
521
522
522
523
// Get implements storage.Interface.
523
- func (c * Cacher ) Get (ctx context.Context , key string , resourceVersion string , objPtr runtime.Object , ignoreNotFound bool ) error {
524
- if resourceVersion == "" {
524
+ func (c * Cacher ) Get (ctx context.Context , key string , opts storage. GetOptions , objPtr runtime.Object ) error {
525
+ if opts . ResourceVersion == "" {
525
526
// If resourceVersion is not specified, serve it from underlying
526
527
// storage (for backward compatibility).
527
- return c .storage .Get (ctx , key , resourceVersion , objPtr , ignoreNotFound )
528
+ return c .storage .Get (ctx , key , opts , objPtr )
528
529
}
529
530
530
531
// If resourceVersion is specified, serve it from cache.
531
532
// It's guaranteed that the returned value is at least that
532
533
// fresh as the given resourceVersion.
533
- getRV , err := c .versioner .ParseResourceVersion (resourceVersion )
534
+ getRV , err := c .versioner .ParseResourceVersion (opts . ResourceVersion )
534
535
if err != nil {
535
536
return err
536
537
}
537
538
538
539
if getRV == 0 && ! c .ready .check () {
539
540
// If Cacher is not yet initialized and we don't require any specific
540
541
// minimal resource version, simply forward the request to storage.
541
- return c .storage .Get (ctx , key , resourceVersion , objPtr , ignoreNotFound )
542
+ return c .storage .Get (ctx , key , opts , objPtr )
542
543
}
543
544
544
545
// Do not create a trace - it's not for free and there are tons
@@ -563,15 +564,17 @@ func (c *Cacher) Get(ctx context.Context, key string, resourceVersion string, ob
563
564
objVal .Set (reflect .ValueOf (elem .Object ).Elem ())
564
565
} else {
565
566
objVal .Set (reflect .Zero (objVal .Type ()))
566
- if ! ignoreNotFound {
567
+ if ! opts . IgnoreNotFound {
567
568
return storage .NewKeyNotFoundError (key , int64 (readResourceVersion ))
568
569
}
569
570
}
570
571
return nil
571
572
}
572
573
573
574
// GetToList implements storage.Interface.
574
- func (c * Cacher ) GetToList (ctx context.Context , key string , resourceVersion string , pred storage.SelectionPredicate , listObj runtime.Object ) error {
575
+ func (c * Cacher ) GetToList (ctx context.Context , key string , opts storage.ListOptions , listObj runtime.Object ) error {
576
+ resourceVersion := opts .ResourceVersion
577
+ pred := opts .Predicate
575
578
pagingEnabled := utilfeature .DefaultFeatureGate .Enabled (features .APIListChunking )
576
579
hasContinuation := pagingEnabled && len (pred .Continue ) > 0
577
580
hasLimit := pagingEnabled && pred .Limit > 0 && resourceVersion != "0"
@@ -582,7 +585,7 @@ func (c *Cacher) GetToList(ctx context.Context, key string, resourceVersion stri
582
585
// Limits are only sent to storage when resourceVersion is non-zero
583
586
// since the watch cache isn't able to perform continuations, and
584
587
// limits are ignored when resource version is zero
585
- return c .storage .GetToList (ctx , key , resourceVersion , pred , listObj )
588
+ return c .storage .GetToList (ctx , key , opts , listObj )
586
589
}
587
590
588
591
// If resourceVersion is specified, serve it from cache.
@@ -596,7 +599,7 @@ func (c *Cacher) GetToList(ctx context.Context, key string, resourceVersion stri
596
599
if listRV == 0 && ! c .ready .check () {
597
600
// If Cacher is not yet initialized and we don't require any specific
598
601
// minimal resource version, simply forward the request to storage.
599
- return c .storage .GetToList (ctx , key , resourceVersion , pred , listObj )
602
+ return c .storage .GetToList (ctx , key , opts , listObj )
600
603
}
601
604
602
605
trace := utiltrace .New ("cacher list" , utiltrace.Field {"type" , c .objectType .String ()})
@@ -643,7 +646,9 @@ func (c *Cacher) GetToList(ctx context.Context, key string, resourceVersion stri
643
646
}
644
647
645
648
// List implements storage.Interface.
646
- func (c * Cacher ) List (ctx context.Context , key string , resourceVersion string , pred storage.SelectionPredicate , listObj runtime.Object ) error {
649
+ func (c * Cacher ) List (ctx context.Context , key string , opts storage.ListOptions , listObj runtime.Object ) error {
650
+ resourceVersion := opts .ResourceVersion
651
+ pred := opts .Predicate
647
652
pagingEnabled := utilfeature .DefaultFeatureGate .Enabled (features .APIListChunking )
648
653
hasContinuation := pagingEnabled && len (pred .Continue ) > 0
649
654
hasLimit := pagingEnabled && pred .Limit > 0 && resourceVersion != "0"
@@ -654,7 +659,7 @@ func (c *Cacher) List(ctx context.Context, key string, resourceVersion string, p
654
659
// Limits are only sent to storage when resourceVersion is non-zero
655
660
// since the watch cache isn't able to perform continuations, and
656
661
// limits are ignored when resource version is zero.
657
- return c .storage .List (ctx , key , resourceVersion , pred , listObj )
662
+ return c .storage .List (ctx , key , opts , listObj )
658
663
}
659
664
660
665
// If resourceVersion is specified, serve it from cache.
@@ -668,7 +673,7 @@ func (c *Cacher) List(ctx context.Context, key string, resourceVersion string, p
668
673
if listRV == 0 && ! c .ready .check () {
669
674
// If Cacher is not yet initialized and we don't require any specific
670
675
// minimal resource version, simply forward the request to storage.
671
- return c .storage .List (ctx , key , resourceVersion , pred , listObj )
676
+ return c .storage .List (ctx , key , opts , listObj )
672
677
}
673
678
674
679
trace := utiltrace .New ("cacher list" , utiltrace.Field {"type" , c .objectType .String ()})
@@ -1083,15 +1088,15 @@ func (lw *cacherListerWatcher) List(options metav1.ListOptions) (runtime.Object,
1083
1088
Continue : options .Continue ,
1084
1089
}
1085
1090
1086
- if err := lw .storage .List (context .TODO (), lw .resourcePrefix , "" , pred , list ); err != nil {
1091
+ if err := lw .storage .List (context .TODO (), lw .resourcePrefix , storage. ListOptions { Predicate : pred } , list ); err != nil {
1087
1092
return nil , err
1088
1093
}
1089
1094
return list , nil
1090
1095
}
1091
1096
1092
1097
// Implements cache.ListerWatcher interface.
1093
1098
func (lw * cacherListerWatcher ) Watch (options metav1.ListOptions ) (watch.Interface , error ) {
1094
- return lw .storage .WatchList (context .TODO (), lw .resourcePrefix , options .ResourceVersion , storage .Everything )
1099
+ return lw .storage .WatchList (context .TODO (), lw .resourcePrefix , storage. ListOptions { ResourceVersion : options .ResourceVersion , Predicate : storage .Everything } )
1095
1100
}
1096
1101
1097
1102
// errWatcher implements watch.Interface to return a single error
0 commit comments