Merge "Deal with gitea pagination of repo lists"
This commit is contained in:
commit
d673281a75
@ -99,8 +99,22 @@ class Gitea(object):
|
|||||||
self.log("Added gerrit to team:", org)
|
self.log("Added gerrit to team:", org)
|
||||||
|
|
||||||
def get_org_repo_list(self, org):
|
def get_org_repo_list(self, org):
|
||||||
return [x['full_name'] for x in
|
params = { 'limit': 50, 'page': 1 }
|
||||||
self.get('/api/v1/orgs/{org}/repos'.format(org=org)).json()]
|
repos = []
|
||||||
|
gitea_data = self.get(
|
||||||
|
'/api/v1/orgs/{org}/repos'.format(org=org),
|
||||||
|
params=params
|
||||||
|
).json()
|
||||||
|
while gitea_data:
|
||||||
|
repos.extend([x['full_name'] for x in gitea_data])
|
||||||
|
# Gitea paginates and returns an empty list at the end of the
|
||||||
|
# listing. 50 items is the max limit.
|
||||||
|
params['page'] += 1
|
||||||
|
gitea_data = self.get(
|
||||||
|
'/api/v1/orgs/{org}/repos'.format(org=org),
|
||||||
|
params=params
|
||||||
|
).json()
|
||||||
|
return repos
|
||||||
|
|
||||||
def get_csrf_token(self):
|
def get_csrf_token(self):
|
||||||
resp = self.get('/')
|
resp = self.get('/')
|
||||||
@ -182,10 +196,18 @@ class Gitea(object):
|
|||||||
def make_projects(self, projects, gitea_repos, csrf_token,
|
def make_projects(self, projects, gitea_repos, csrf_token,
|
||||||
settings_thread_pool, branches_thread_pool, futures):
|
settings_thread_pool, branches_thread_pool, futures):
|
||||||
for project in projects:
|
for project in projects:
|
||||||
if project['project'] in gitea_repos:
|
create = False
|
||||||
create = False
|
if project['project'] not in gitea_repos:
|
||||||
else:
|
try:
|
||||||
create = True
|
self.get('/' + project['project'])
|
||||||
|
except requests.HTTPError:
|
||||||
|
# If the project isn't in the listing we do an explicit
|
||||||
|
# check for its existence. This is because gitea repo
|
||||||
|
# listings require pagination and they don't use stable
|
||||||
|
# sorting and that causes problems reliably producing a
|
||||||
|
# complete repo list. If we cannot find the project
|
||||||
|
# then create it.
|
||||||
|
create = True
|
||||||
if create:
|
if create:
|
||||||
# TODO: use threadpool when we're running with
|
# TODO: use threadpool when we're running with
|
||||||
# https://github.com/go-gitea/gitea/pull/7493
|
# https://github.com/go-gitea/gitea/pull/7493
|
||||||
|
@ -500,6 +500,9 @@
|
|||||||
- playbooks/service-gitea-lb.yaml
|
- playbooks/service-gitea-lb.yaml
|
||||||
- playbooks/service-gitea.yaml
|
- playbooks/service-gitea.yaml
|
||||||
- playbooks/manage-projects.yaml
|
- playbooks/manage-projects.yaml
|
||||||
|
# Run twice to ensure that we noop properly when
|
||||||
|
# all projects are created in gitea.
|
||||||
|
- playbooks/manage-projects.yaml
|
||||||
run_test_playbook: playbooks/test-gitea.yaml
|
run_test_playbook: playbooks/test-gitea.yaml
|
||||||
host-vars:
|
host-vars:
|
||||||
gitea99.opendev.org:
|
gitea99.opendev.org:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user