Skip to content
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)
}
}