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)
| 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. |
| 202 | func (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 | } |
no test coverage detected