From 50ff06c7edf8d8b0960d930fc3beeae4b4cfd89f Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Jun 10 2020 17:36:23 +0000 Subject: Remove pdcclient since it is not available in epel8. We don't make a big use of pdcclient so let's replace it with a requests.get call. This commit does not manage the pagination but since the code raise a ValueError is the request response contains more than 1 result we should not need to manage the pagination. Signed-off-by: Clement Verna --- diff --git a/dist_git_auth.py b/dist_git_auth.py index 28d274f..d28bdd5 100644 --- a/dist_git_auth.py +++ b/dist_git_auth.py @@ -17,10 +17,7 @@ import logging import re import os -try: - from pdc_client import PDCClient -except ImportError: - PDCClient = None +import requests if "PAGURE_CONFIG" not in os.environ and os.path.exists( @@ -76,11 +73,7 @@ class DistGitAuth(GitAuthHelper): "ACL_PROTECTED_NAMESPACES", ["rpms"] ) - pdc_url = pagure_config.get("PDC_URL") - if pdc_url and PDCClient: - self.pdcclient = PDCClient(pdc_url, develop=True) - else: - self.pdcclient = None + self.pdc_url = pagure_config.get("PDC_URL") def is_supported_branch(self, project, refname): """ Returns whether a specific branch is currently supported for Fedora @@ -88,7 +81,7 @@ class DistGitAuth(GitAuthHelper): This retrieves the information about EOL status from PDC, to prevent EOL branches being pushed to. """ - if not self.pdcclient: + if not self.pdc_url: # No way to confirm this is a supported branch, not supported return None if not refname.startswith("refs/heads/"): @@ -101,15 +94,15 @@ class DistGitAuth(GitAuthHelper): "modules": "module", "container": "container", } - res = list( - self.pdcclient.get_paged( - self.pdcclient["component-branches"], - global_component=project.name, - type=namespace2pdctype[project.namespace], - name=refname, - fields=["active"], - ) + resp = requests.get( + f"{self.pdc_url}component-branches/?global_component={project.name}" + f"&name={refname}&type={namespace2pdctype[project.namespace]}&fields=active" ) + + res = [] + if resp.ok: + res = resp.json().get("results") + if len(res) == 0: # No status return None