diff options
author | Parker Berberian <pberberian@iol.unh.edu> | 2018-12-14 09:29:25 -0500 |
---|---|---|
committer | Parker Berberian <pberberian@iol.unh.edu> | 2018-12-14 09:29:25 -0500 |
commit | e04ff97b11ffe467a66c229728a90f374bce41dc (patch) | |
tree | f82a6007c607d6341b5792bbbd9a61772ed075f6 /dashboard | |
parent | 9ae6c5c1cef2c5488b5c7c7700c886f8ebfe9d00 (diff) |
Checks Sub Project Leads
Fatih Pointed out to me the existence of ptl's of sub projects,
which show up differently in the INFO.yaml files.
This commit also adds support for gerrit.opnfv.org and git.opnfv.org links.
I don't remember why we were only accepting github links, but that seems strange.
Change-Id: Ica64c4ee7d5c0ce4fa6bfbcbabb1c4ca7cf06018
Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'dashboard')
-rw-r--r-- | dashboard/src/workflow/models.py | 85 |
1 files changed, 77 insertions, 8 deletions
diff --git a/dashboard/src/workflow/models.py b/dashboard/src/workflow/models.py index 966582c..bed6f52 100644 --- a/dashboard/src/workflow/models.py +++ b/dashboard/src/workflow/models.py @@ -26,13 +26,11 @@ from booking.models import Booking class BookingAuthManager(): LFN_PROJECTS = ["opnfv"] # TODO - def parse_url(self, info_url): - """ - will return the PTL in the INFO file on success, or None - """ + def parse_github_url(self, url): + project_leads = [] try: - parts = info_url.split("/") - if parts[0].find("http") > -1: # the url include http(s):// + parts = url.split("/") + if "http" in parts[0]: # the url include http(s):// parts = parts[2:] if parts[-1] != "INFO.yaml": return None @@ -47,13 +45,84 @@ class BookingAuthManager(): info_file = requests.get(url, timeout=15).text info_parsed = yaml.load(info_file) ptl = info_parsed.get('project_lead') - if not ptl: + if ptl: + project_leads.append(ptl) + sub_ptl = info_parsed.get("subproject_lead") + if sub_ptl: + project_leads.append(sub_ptl) + + except Exception: + pass + + return project_leads + + def parse_gerrit_url(self, url): + project_leads = [] + try: + parts = url.split("/") + if "http" in parts[0]: # the url include http(s):// + parts = parts[2:] + if "f=INFO.yaml" not in parts[-1].split(";"): + return None + if "gerrit.opnfv.org" not in parts[0]: return None - return ptl + # now to download and parse file + url = "https://" + "/".join(parts) + info_file = requests.get(url, timeout=15).text + info_parsed = yaml.load(info_file) + ptl = info_parsed.get('project_lead') + if ptl: + project_leads.append(ptl) + sub_ptl = info_parsed.get("subproject_lead") + if sub_ptl: + project_leads.append(sub_ptl) except Exception: return None + return project_leads + + def parse_opnfv_git_url(self, url): + project_leads = [] + try: + parts = url.split("/") + if "http" in parts[0]: # the url include http(s):// + parts = parts[2:] + if "INFO.yaml" not in parts[-1]: + return None + if "git.opnfv.org" not in parts[0]: + return None + if parts[-2] == "tree": + parts[-2] = "plain" + # now to download and parse file + url = "https://" + "/".join(parts) + info_file = requests.get(url, timeout=15).text + info_parsed = yaml.load(info_file) + ptl = info_parsed.get('project_lead') + if ptl: + project_leads.append(ptl) + sub_ptl = info_parsed.get("subproject_lead") + if sub_ptl: + project_leads.append(sub_ptl) + + except Exception: + return None + + return project_leads + + def parse_url(self, info_url): + """ + will return the PTL in the INFO file on success, or None + """ + if "github" in info_url: + return self.parse_github_url(info_url) + + if "gerrit.opnfv.org" in info_url: + return self.parse_gerrit_url(info_url) + + if "git.opnfv.org" in info_url: + return self.parse_opnfv_git_url(info_url) + def booking_allowed(self, booking, repo): """ This is the method that will have to change whenever the booking policy changes in the Infra |