WIP: Improve search method
Hello @deitch
I was working in a different project, where we tune the query to the "_catalog" endpoint to get more or less records per page. So I then imagined that we could have the same in the docker_registry2 gem.
So the default is 100 records per page, so thats what i set on the search method. I "precompiled" the regex used in the search method, matching the query, outside of the each loop, since it doesnt change.
Lets see if it works 👍
P.S: Ops it looks like I have to regenerate the VCR files. Nice CI pipeline you have here 😊
Heh, didn't you add the spec in? 😁
The prior behavior fetched them all? It looks like this adds not just an option to limit, but a default limit that did not exist before? Is that a breaking change?
The prior behavior fetched them all? It looks like this adds not just an option to limit, but a default limit that did not exist before? Is that a breaking change?
the default is 100 entries per page. We could for sure make the "n" optional and if nothing gets passed it gets the /_catalog as before. I will add a spec too to make sure that the n influences the number of returned entries per page
Reference: https://distribution.github.io/distribution/spec/api/
So you are saying that the default is 100. This PR just makes it explicit, but that is what happens anyways? OK, then fine with me.
I approved it, just waiting for the spec you said you wanted to add.
@deitch
So you are saying that the default is 100. This PR just makes it explicit, but that is what happens anyways?
Exactly, the default page size for the docker official registry is 100. I will add a spec for that. Maybe we should keep the query to the "_catalog" in case people are using a different registry backend and are expecting other value there.
I approved it, just waiting for the spec you said you wanted to add.
spec will come 👍
Hi @deitch
While running the local registry with docker-compose up i realized, that our local images are in the v1 format, which isnt supported anymore by the new registries?
Anyway with the commands:
docker-compose up
docker pull localhost:5000/hello-world-v1
skopeo copy --dest-tls-verify=false docker-daemon:hello-world-v1:latest docker://localhost:5000/hello-world-v1:latest
I was able to convert the manifest from v1 to v2
I created some images locally to test the "/v2/_catalog" with the following script (that I will add to the PR)
#!/bin/bash
# Source image
source_image="localhost:5000/hello-world-v1:latest"
# Registry URL
registry_url="localhost:5000"
# Iterating from 2 to 101
for counter in {2..101}
do
# Destination image name
dest_image="$registry_url/hello-world-v$counter:latest"
# Skopeo copy command
skopeo copy --dest-tls-verify=false "docker-daemon:$source_image" "docker://$dest_image"
# Optional: Echo to track progress
echo "Copied to $dest_image"
done
Then to make sure that we have more than 100 images in the catalog:
$ curl -s http://localhost:5000/v2/_catalog?n=300 | jq '.repositories | length'
203
Lets check the default of calling /v2/_catalog:
$ curl -s http://localhost:5000/v2/_catalog | jq '.repositories | length'
100
So like that I'm sure the default are 100 results. I will now add the spec to make sure that we can control this value, i.e having 3 images named hello-world-{1,2,3} on my registry, i can spec that passing arbitrary values to the search method can influence the number of returned results