Support api chunking in kubectl get

This enables chunking in the resource builder to make it easy to
retrieve resources in pages and visit partial result sets. This adds
`--chunk-size` to `kubectl get` only so that users can get comfortable
with the use of chunking in beta. Future changes will enable chunking
for all CLI commands so that bulk actions can be performed more
efficiently.
This commit is contained in:
Clayton Coleman
2017-10-12 00:06:17 -04:00
parent b1e2d7a9dc
commit 4780ad0297
9 changed files with 110 additions and 39 deletions

View File

@@ -56,6 +56,7 @@ type Builder struct {
selector *string
selectAll bool
includeUninitialized bool
limitChunks int64
resources []string
@@ -355,6 +356,14 @@ func (b *Builder) RequireNamespace() *Builder {
return b
}
// RequestChunksOf attempts to load responses from the server in batches of size limit
// to avoid long delays loading and transferring very large lists. If unset defaults to
// no chunking.
func (b *Builder) RequestChunksOf(chunkSize int64) *Builder {
b.limitChunks = chunkSize
return b
}
// SelectEverythingParam
func (b *Builder) SelectAllParam(selectAll bool) *Builder {
if selectAll && b.selector != nil {
@@ -653,7 +662,7 @@ func (b *Builder) visitBySelector() *Result {
if mapping.Scope.Name() != meta.RESTScopeNameNamespace {
selectorNamespace = ""
}
visitors = append(visitors, NewSelector(client, mapping, selectorNamespace, *b.selector, b.export, b.includeUninitialized))
visitors = append(visitors, NewSelector(client, mapping, selectorNamespace, *b.selector, b.export, b.includeUninitialized, b.limitChunks))
}
if b.continueOnError {
result.visitor = EagerVisitorList(visitors)