Support pagination in the installation map

When listing repos of an installation github by default only returns
30 repos. One can request more but at most 100. In case there are more
than 100 repos in an organization we must use pagination in order to
prime the installation map including all repos.

Change-Id: Ie8f2ae4226eaa7b684c72622a9f80689825150bb
This commit is contained in:
Tobias Henkel 2018-03-06 12:24:54 +01:00
parent f703cc762c
commit d54d1a1b60
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2
1 changed files with 11 additions and 8 deletions

View File

@ -650,16 +650,19 @@ class GithubConnection(BaseConnection):
headers = {'Accept': PREVIEW_JSON_ACCEPT,
'Authorization': 'token %s' % token}
url = '%s/installation/repositories' % self.base_url
url = '%s/installation/repositories?per_page=100' % self.base_url
while url:
self.log.debug("Fetching repos for install %s" % inst_id)
response = requests.get(url, headers=headers)
response.raise_for_status()
repos = response.json()
self.log.debug("Fetching repos for install %s" % inst_id)
response = requests.get(url, headers=headers)
response.raise_for_status()
repos = response.json()
for repo in repos.get('repositories'):
project_name = repo.get('full_name')
self.installation_map[project_name] = inst_id
for repo in repos.get('repositories'):
project_name = repo.get('full_name')
self.installation_map[project_name] = inst_id
# check if we need to do further paged calls
url = response.links.get('next', {}).get('url')
def addEvent(self, data, event=None):
return self.event_queue.put((time.time(), data, event))