mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-02-23 11:21:13 +00:00
CloudPolicy: Support public PPAs with fingerprints
Updates the _parse_ppas function to also allow public PPAs with fingerprints to be provided (team/name:fingerprint).
This commit is contained in:
parent
2bd1584c84
commit
f21d94d3b2
@ -69,7 +69,7 @@ class CloudPolicy(BasePolicy):
|
||||
self.failure_emails = getattr(self.options, "cloud_failure_emails", self.DEFAULT_EMAILS)
|
||||
self.error_emails = getattr(self.options, "cloud_error_emails", self.DEFAULT_EMAILS)
|
||||
|
||||
adt_ppas = getattr(self.options, "adt_ppas", [])
|
||||
adt_ppas = getattr(self.options, "adt_ppas", "").split()
|
||||
ppas = self._parse_ppas(adt_ppas)
|
||||
|
||||
if len(ppas) == 0:
|
||||
@ -402,13 +402,16 @@ class CloudPolicy(BasePolicy):
|
||||
def _parse_ppas(self, ppas):
|
||||
"""Parse PPA list to store in format expected by cloud tests
|
||||
|
||||
Since currently only private PPAs in Britney are provided with fingerprints we will
|
||||
only use those.
|
||||
Only supports PPAs provided with a fingerprint
|
||||
|
||||
Britney private PPA format:
|
||||
'user:token@team/name:fingerprint'
|
||||
Britney public PPA format:
|
||||
'team/name:fingerprint'
|
||||
Cloud private PPA format:
|
||||
'https://user:token@private-ppa.launchpadcontent.net/team/name/ubuntu=fingerprint
|
||||
Cloud public PPA format:
|
||||
'https://ppa.launchpadcontent.net/team/name/ubuntu=fingerprint
|
||||
|
||||
:param ppas List of PPAs in Britney approved format
|
||||
:return A list of PPAs in valid cloud test format. Can return an empty list if none found.
|
||||
@ -425,6 +428,15 @@ class CloudPolicy(BasePolicy):
|
||||
match.group("auth"), match.group("name"), match.group("fingerprint")
|
||||
)
|
||||
cloud_ppas.append(formatted_ppa)
|
||||
else:
|
||||
match = re.match("^(?P<name>.+):(?P<fingerprint>.+$)", ppa)
|
||||
if not match:
|
||||
raise RuntimeError('Public PPA %s not following required format (team/name:fingerprint)', ppa)
|
||||
|
||||
formatted_ppa = "https://ppa.launchpadcontent.net/{}/ubuntu={}".format(
|
||||
match.group("name"), match.group("fingerprint")
|
||||
)
|
||||
cloud_ppas.append(formatted_ppa)
|
||||
|
||||
return cloud_ppas
|
||||
|
||||
|
@ -201,11 +201,12 @@ class T(unittest.TestCase):
|
||||
tests.
|
||||
"""
|
||||
input_ppas = [
|
||||
"deadsnakes/ppa",
|
||||
"deadsnakes/ppa:fingerprint",
|
||||
"user:token@team/name:fingerprint"
|
||||
]
|
||||
|
||||
expected_ppas = [
|
||||
"https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu=fingerprint",
|
||||
"https://user:token@private-ppa.launchpadcontent.net/team/name/ubuntu=fingerprint"
|
||||
]
|
||||
|
||||
@ -214,6 +215,10 @@ class T(unittest.TestCase):
|
||||
|
||||
def test_errors_raised_if_invalid_ppa_input(self):
|
||||
"""Test that error are raised if input PPAs don't match expected format"""
|
||||
self.assertRaises(
|
||||
RuntimeError, self.policy._parse_ppas, ["team/name"]
|
||||
)
|
||||
|
||||
self.assertRaises(
|
||||
RuntimeError, self.policy._parse_ppas, ["user:token@team/name"]
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user