Pagination is not handled in `search` method
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!
correct, it is missing that. Nice catch.
Definitely open to a PR for it.
I'm not at all a Ruby developer, but could you have a look at the above PR when you have time, please?
Thanks!