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

feat: support oras discover pass pagination args #1525

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions cmd/oras/root/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/spf13/cobra"
"oras.land/oras-go/v2/registry/remote"

"oras.land/oras-go/v2"
"oras.land/oras-go/v2/registry"
Expand All @@ -40,6 +41,7 @@
option.Format

artifactType string
pageSize int
}

func discoverCmd() *cobra.Command {
Expand Down Expand Up @@ -98,6 +100,9 @@
}

cmd.Flags().StringVarP(&opts.artifactType, "artifact-type", "", "", "artifact type")
// If zero, the page size is determined by the remote registry.
// Reference: https://github.com/opencontainers/distribution-spec/blob/v1.1.0/spec.md#listing-referrers
cmd.Flags().IntVarP(&opts.pageSize, "page-size", "", 0, "page size for discover pagination")
cmd.Flags().StringVarP(&opts.Format.FormatFlag, "output", "o", "tree", "[Deprecated] format in which to display referrers (table, json, or tree). tree format will also show indirect referrers")
opts.SetTypes(
option.FormatTypeTree,
Expand All @@ -116,6 +121,11 @@
if err != nil {
return err
}
if r, ok := repo.(*remote.Repository); ok {
if opts.pageSize > 0 {

Check warning on line 125 in cmd/oras/root/discover.go

View check run for this annotation

Codecov / codecov/patch

cmd/oras/root/discover.go#L124-L125

Added lines #L124 - L125 were not covered by tests
r.ReferrerListPageSize = opts.pageSize
}
}

Check warning on line 128 in cmd/oras/root/discover.go

View check run for this annotation

Codecov / codecov/patch

cmd/oras/root/discover.go#L128

Added line #L128 was not covered by tests
if err := opts.EnsureReferenceNotEmpty(cmd, true); err != nil {
return err
}
Expand Down
Loading