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

Pagination is not handled in search method #57

Open
UncleIS opened this issue Oct 26, 2021 · 2 comments
Open

Pagination is not handled in search method #57

UncleIS opened this issue Oct 26, 2021 · 2 comments

Comments

@UncleIS
Copy link

UncleIS commented Oct 26, 2021

Hi!

We noticed recently that pagination is not handled properly in the search method:

def search(query = '')
    response = doget "/v2/_catalog"
    # parse the response
    repos = JSON.parse(response)["repositories"]
    if query.strip.length > 0
      re = Regexp.new query
      repos = repos.find_all {|e| re =~ e }
    end
    return repos
  end

The doget "/v2/_catalog" part above works fine in case the registry does not produce the paginated output, but returns only the first page in case it does. In my case, we talk to a private registry that refuses to return a list longer than 100 items, while we have almost 300 of the repositories.

Here are how the headers look like after the doget response has been acquired:

[3] pry(#<DockerRegistry2::Registry>)> response.headers
=> {:server=>"nginx/1.15.6",
 :date=>"Tue, 26 Oct 2021 13:11:36 GMT",
 :content_type=>"application/json",
 :transfer_encoding=>"chunked",
 :connection=>"keep-alive",
 :vary=>"Accept-Encoding, Origin",
 :docker_distribution_api_version=>"registry/2.0",
 :link=>"</v2/_catalog?last=myproject%2F1dx%2Fone_of_my_images&n=100>; rel=\"next\"",
 :strict_transport_security=>"max-age=15724800; includeSubDomains"}

The API itself is described here: https://docs.docker.com/registry/spec/api/#listing-repositories

Thanks!

@deitch
Copy link
Owner

deitch commented Oct 26, 2021

correct, it is missing that. Nice catch.

Definitely open to a PR for it.

@UncleIS
Copy link
Author

UncleIS commented Oct 27, 2021

I'm not at all a Ruby developer, but could you have a look at the above PR when you have time, please?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants