From 06d97b8dd3d6ae9d124403afe0b2ddd6baf81982 Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Jun 24 2020 09:59:24 +0000 Subject: Since Pagure 5.9 add by default Zuul as Ticket collaborator To avoid using webhook payload source whitelisting Pagure 5.9 provided an endpoint to fetch the webhook token from the API with the minimum required ACL collaborator level: ticket. Zuul can now use that endpoint to fetch the token. This change ensure the zuul user is added as Ticket collaborator in projects. --- diff --git a/tools/project-settings-helper/README.md b/tools/project-settings-helper/README.md index 094b0b7..18044bf 100644 --- a/tools/project-settings-helper/README.md +++ b/tools/project-settings-helper/README.md @@ -6,7 +6,7 @@ instance to integrate with Zuul. Indeed some specific settings are needed. See: https://fedoraproject.org/wiki/Zuul-based-ci#Configure_the_repository_for_Zuul -To create the API key: +An API key is needed to use that tool, to create it: - https://src.fedoraproject.org/settings - API keys - Create key with "Modify an existing project" right diff --git a/tools/project-settings-helper/helper.py b/tools/project-settings-helper/helper.py index e442ab8..f5c06d4 100755 --- a/tools/project-settings-helper/helper.py +++ b/tools/project-settings-helper/helper.py @@ -82,6 +82,7 @@ class PagureAPIClient(): def set_zuul_settings(client, project, gating, host): logging.debug("Get settings config on %s" % project) + acl_level = 'ticket' config = client.get_config(project) config['Web-hooks'] = BASE_WH_URL % host config['pull_requests'] = True @@ -89,20 +90,22 @@ def set_zuul_settings(client, project, gating, host): config['Minimum_score_to_merge_pull-request'] = 0 config['open_metadata_access_to_all'] = False client.set_tags(project, ['gateit']) + acl_level = 'commit' # convert value https://pagure.io/pagure/issue/4712 for k, v in config.items(): if isinstance(v, bool): config[k] = 1 if v else 0 client.set_config(project, config) logging.debug("Applying new setting set on %s" % project) - if gating: - acls = { - 'user_type': 'user', - 'name': 'zuul', - 'acl': 'commit' - } - client.set_acl(project, acls) - logging.debug("Adding zuul user as admin on %s" % project) + acls = { + 'user_type': 'user', + 'name': 'zuul', + 'acl': acl_level + } + client.set_acl(project, acls) + logging.debug( + "Adding zuul user as %s collaborator on %s" % ( + acl_level, project)) def process(client, projects, gating, host):