From 02792fc20e6965213789fbd214c670cd5ef0fe11 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 10 Dec 2024 19:35:10 +0100 Subject: [PATCH] bekkalokk/gitea: fix api pagination for web secret provider --- .../gitea-web-secret-provider.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hosts/bekkalokk/services/gitea/web-secret-provider/gitea-web-secret-provider.py b/hosts/bekkalokk/services/gitea/web-secret-provider/gitea-web-secret-provider.py index beee4c6..fe8bfff 100644 --- a/hosts/bekkalokk/services/gitea/web-secret-provider/gitea-web-secret-provider.py +++ b/hosts/bekkalokk/services/gitea/web-secret-provider/gitea-web-secret-provider.py @@ -34,7 +34,21 @@ def get_org_repo_list(args: argparse.Namespace, token: str): f"{args.api_url}/orgs/{args.org}/repos", headers = { 'Authorization': 'token ' + token }, ) - return [repo["name"] for repo in result.json()] + + results = [repo["name"] for repo in result.json()] + target = int(result.headers['X-Total-Count']) + + i = 2 + while len(results) < target: + result = requests.get( + f"{args.api_url}/orgs/{args.org}/repos", + params = { 'page': i }, + headers = { 'Authorization': 'token ' + token }, + ) + results += [repo["name"] for repo in result.json()] + i += 1 + + return results def generate_ssh_key(args: argparse.Namespace, repository: str):