mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-04 10:46:16 +00:00
client-go/gentype: remove watchlist
Kubernetes-commit: 2f943293ed80e329141a0b8ab8ce093416c456c7
This commit is contained in:
parent
4e82e68412
commit
3fab93670b
@ -27,9 +27,6 @@ import (
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
rest "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/util/apply"
|
||||
"k8s.io/client-go/util/consistencydetector"
|
||||
"k8s.io/client-go/util/watchlist"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
// objectWithMeta matches objects implementing both runtime.Object and metav1.Object.
|
||||
@ -172,24 +169,6 @@ func (c *Client[T]) Get(ctx context.Context, name string, options metav1.GetOpti
|
||||
|
||||
// List takes label and field selectors, and returns the list of resources that match those selectors.
|
||||
func (l *alsoLister[T, L]) List(ctx context.Context, opts metav1.ListOptions) (L, error) {
|
||||
if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil {
|
||||
klog.Warningf("Failed preparing watchlist options for $.type|resource$, falling back to the standard LIST semantics, err = %v", watchListOptionsErr)
|
||||
} else if hasWatchListOptionsPrepared {
|
||||
result, err := l.watchList(ctx, watchListOptions)
|
||||
if err == nil {
|
||||
consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for "+l.client.resource, l.list, opts, result)
|
||||
return result, nil
|
||||
}
|
||||
klog.Warningf("The watchlist request for %s ended with an error, falling back to the standard LIST semantics, err = %v", l.client.resource, err)
|
||||
}
|
||||
result, err := l.list(ctx, opts)
|
||||
if err == nil {
|
||||
consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for "+l.client.resource, l.list, opts, result)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (l *alsoLister[T, L]) list(ctx context.Context, opts metav1.ListOptions) (L, error) {
|
||||
list := l.newList()
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
@ -206,24 +185,6 @@ func (l *alsoLister[T, L]) list(ctx context.Context, opts metav1.ListOptions) (L
|
||||
return list, err
|
||||
}
|
||||
|
||||
// watchList establishes a watch stream with the server and returns the list of resources.
|
||||
func (l *alsoLister[T, L]) watchList(ctx context.Context, opts metav1.ListOptions) (result L, err error) {
|
||||
var timeout time.Duration
|
||||
if opts.TimeoutSeconds != nil {
|
||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||
}
|
||||
result = l.newList()
|
||||
err = l.client.client.Get().
|
||||
UseProtobufAsDefaultIfPreferred(l.client.prefersProtobuf).
|
||||
NamespaceIfScoped(l.client.namespace, l.client.namespace != "").
|
||||
Resource(l.client.resource).
|
||||
VersionedParams(&opts, l.client.parameterCodec).
|
||||
Timeout(timeout).
|
||||
WatchList(ctx).
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested resources.
|
||||
func (c *Client[T]) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
var timeout time.Duration
|
||||
|
Loading…
Reference in New Issue
Block a user