MCPcopy
hub / github.com/kubernetes/client-go / eachListChunk

Method eachListChunk

tools/pager/pager.go:202–231  ·  view source on GitHub ↗

eachListChunk fetches runtimeObject list chunks using this ListPager and invokes fn on each list chunk. If fn returns an error, processing stops and that error is returned. If fn does not return an error, any error encountered while retrieving the list from the server is returned. If the context can

(ctx context.Context, options metav1.ListOptions, fn func(obj runtime.Object) error)

Source from the content-addressed store, hash-verified

200// paginated chunks, an "Expired" error (metav1.StatusReasonExpired) may be returned if the
201// pagination list requests exceed the expiration limit of the apiserver being called.
202func (p *ListPager) eachListChunk(ctx context.Context, options metav1.ListOptions, fn func(obj runtime.Object) error) error {
203 if options.Limit == 0 {
204 options.Limit = p.PageSize
205 }
206 for {
207 select {
208 case <-ctx.Done():
209 return ctx.Err()
210 default:
211 }
212
213 obj, err := p.PageFn(ctx, options)
214 if err != nil {
215 return err
216 }
217 m, err := meta.ListAccessor(obj)
218 if err != nil {
219 return fmt.Errorf("returned object must be a list: %v", err)
220 }
221 if err := fn(obj); err != nil {
222 return err
223 }
224 // if we have no more items, return.
225 if len(m.GetContinue()) == 0 {
226 return nil
227 }
228 // set the next loop up
229 options.Continue = m.GetContinue()
230 }
231}

Callers 1

eachListChunkBufferedMethod · 0.95

Calls 2

DoneMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected