Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crane package options modified exposing WithPageSize #2062

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/crane/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type Options struct {
jobs int
noclobber bool
ctx context.Context
// pageSize for paginations
pageSize int
}

// GetOptions exposes the underlying []remote.Option, []name.Option, and
Expand Down Expand Up @@ -176,3 +178,13 @@ func WithNoClobber(noclobber bool) Option {
o.noclobber = noclobber
}
}

// WithPageSize sets the given size as the value of parameter 'n' in the request.
//
// To omit the `n` parameter entirely, use WithPageSize(0).
// The default value is 1000.
func WithPageSize(size int) Option {
return func(o *Options) {
o.pageSize = size
}
}
9 changes: 9 additions & 0 deletions pkg/crane/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ func TestInsecureTransport(t *testing.T) {
t.Errorf("got: %t\nwant: %t", got, want)
}
}

func TestWithPageSize(t *testing.T) {
want := 1000 // default pageSize
opts := GetOptions(WithPageSize(want))

if got := opts.pageSize; got != want {
t.Errorf("got %d\nwant: %d", got, want)
}
}