Add a package owner email alias script to use Pagure instead of PkgDB and stop querying FAS in staging

As part of the Modularity project, we've decided that we need to have different package
branches with different lifecycles. To read more about this, please view this document:
https://fedoraproject.org/wiki/Infrastructure/Factory2/Focus/ArbitraryBranching. To enable
this, we've decided to rely on Pagure and PDC for package information instead of PkgDB.
This commit is an attempt to modify an existing script that queried PkgDB and FAS for packager
emails with one that uses the new architecture described above.

Also, instead of querying FAS for email information, we've decided to use the email alias
USER@fedoraproject.org. This will be a performance increase and protect us against FAS API
changes.
This commit is contained in:
Matt Prahl 2017-04-13 12:29:56 -04:00 committed by Matt Prahl
parent 72e5a57de0
commit 5d4f03b9b9
2 changed files with 66 additions and 7 deletions

View file

@ -0,0 +1,38 @@
#!/usr/bin/python -tt
"""
This script is ran as a cronjob and bastion.
Its goal is to generate all the <pkg>-owner email aliases we provide
"""
import requests
# TODO: Change me
pagure_url = 'http://127.0.0.1:5000'
pagure_group_url = pagure_url + '/api/0/group/{group}'
pagure_projects_url = pagure_url + '/api/0/projects'
pagure_projects = requests.get(pagure_projects_url).json()['projects']
project_to_email = {}
for project in pagure_projects:
users = set(project['access_users']['owner']) | \
set(project['access_users']['admin']) | \
set(project['access_users']['commit'])
groups = set()
for group_kind in ('admin', 'commit'):
for group in project['access_groups'][group_kind]:
groups.add(group)
for group in groups:
group_members = requests.get(
pagure_group_url.format(group=group)).json()['members']
users = users | set(group_members)
# Use the @fedoraproject.org email alias instead of looking their email up
# in FAS
project_to_email[project['name']] = \
['{0}@fedoraproject.org'.format(user) for user in users]
for project, emails in project_to_email.items():
print('{0}: {1}'.format(project, ','.join(sorted(emails))))

View file

@ -1,13 +1,34 @@
---
# Email alias set-up
- name: Install the Python script to get the <pkg>-owner email alias (non-staging)
copy:
src: owner-email.py
dest: /usr/local/bin/owner-email.py
owner: root
group: root
mode: 0755
when: env != 'staging'
tags:
- install
- name: Install the script generating the <pkg>-owner email alias
copy: src={{ item.file }}
dest={{ item.dest }}
owner=root group=root mode=0755
with_items:
- { file: owner-email.py, dest: /usr/local/bin/owner-email.py }
- { file: package-owner-aliases.sh, dest: /etc/cron.hourly/package-owner-aliases.sh }
- name: Install the Python script to get the <pkg>-owner email alias (staging)
copy:
src: owner-email-from-pagure.py
dest: /usr/local/bin/owner-email.py
owner: root
group: root
mode: 0755
when: env == 'staging'
tags:
- install
- name: Install the script to generate the <pkg>-owner email alias
copy:
src: package-owner-aliases.sh
dest: /etc/cron.hourly/package-owner-aliases.sh
owner: root
group: root
mode: 0755
tags:
- install