mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user