jetstack / version-checker

Kubernetes utility for exposing image versions in use, compared to latest available upstream, as metrics.
https://jetstack.io
Apache License 2.0
677 stars 76 forks source link

Handle Paging in clients #59

Open JoshVanL opened 3 years ago

JoshVanL commented 3 years ago

We do not currently properly support paging in clients. This means that tag sets will only include tags which are returned in the first page from the registry. This may lead to incorrect results when reporting the latest image when options have been applied.

We should update our clients to implement proper HTTP paging, to ensure we get the fill list of tag results.

badrul-devops commented 1 year ago

Implementing proper HTTP paging in clients is important to ensure that we get the full list of tag results and avoid incorrect results when reporting the latest image with applied options.

Here are the steps you can take to implement proper HTTP paging in clients:

Determine the API endpoint for fetching tags from the registry. This may vary depending on the registry and the API being used.

Review the API documentation to understand how paging is implemented. Typically, paging is done using query parameters such as "page" and "per_page", or using pagination links in the response headers.

Modify your client to make multiple requests to the API, each time including the appropriate paging parameters. You can use a loop or recursion to make the requests until all pages have been retrieved.

Combine the results from all pages into a single list of tags. You may need to handle duplicates or sort the results depending on your requirements.

Test your implementation thoroughly to ensure it works correctly with different registries, APIs, and paging parameters.

By implementing proper HTTP paging in your clients, you can ensure that you get accurate and complete results when fetching tags from the registry.