feat(client): detect pagination limit at client instantiation

Closes #15
This commit is contained in:
Julien Dessaux 2025-05-25 18:12:46 +02:00
parent f4d69460af
commit 7e1e9eb26b
Signed by: adyxax
GPG key ID: F92E51B86E07177E
4 changed files with 25 additions and 15 deletions

View file

@ -107,7 +107,7 @@ func (c *Client) RepositoriesList(ctx context.Context) ([]Repository, error) {
}
uriRef := url.URL{Path: "api/v1/repos/search"}
query := make(url.Values)
query.Set("limit", maxItemsPerPageStr)
query.Set("limit", c.maxItemsPerPageStr)
page := 1
var repositories []Repository
var response Response
@ -122,7 +122,7 @@ func (c *Client) RepositoriesList(ctx context.Context) ([]Repository, error) {
return nil, fmt.Errorf("got a non OK status when searching repositories")
}
repositories = append(repositories, response.Data...)
if count <= page*maxItemsPerPage {
if count <= page*c.maxItemsPerPage {
return repositories, nil
}
page++