diff --git a/pkg/crane/options.go b/pkg/crane/options.go index d9d441761..36d20ef88 100644 --- a/pkg/crane/options.go +++ b/pkg/crane/options.go @@ -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 @@ -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 + } +} diff --git a/pkg/crane/options_test.go b/pkg/crane/options_test.go index eaee3cf24..7683a2be9 100644 --- a/pkg/crane/options_test.go +++ b/pkg/crane/options_test.go @@ -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) + } +}