From 2de94184b3f5babff811a3c4a92e7ba134359158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=27sil2100=27=20Zemczak?= Date: Mon, 15 Mar 2021 17:27:17 +0100 Subject: [PATCH] Add support for specifying the GPG fingerprint for private PPAs. --- britney2/policies/autopkgtest.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/britney2/policies/autopkgtest.py b/britney2/policies/autopkgtest.py index 6abb862..b25305a 100644 --- a/britney2/policies/autopkgtest.py +++ b/britney2/policies/autopkgtest.py @@ -147,8 +147,10 @@ class AutopkgtestPolicy(BasePolicy): self.swift_container = 'autopkgtest-' + options.series if self.options.adt_ppas: - # private PPAs require the auth credentials given - self.swift_container += '-' + options.adt_ppas[-1].rpartition('@')[2].replace('/', '-') + # private PPAs require the auth credentials given + we allow the + # PPA fingerprint attached at the end + # those need to be removed before the ppa-based name can be used + self.swift_container += '-' + options.adt_ppas[-1].rpartition('@')[2].replace('/', '-').partition(':')[0] # restrict adt_arches to architectures we actually run for self.adt_arches = [] @@ -207,6 +209,18 @@ class AutopkgtestPolicy(BasePolicy): not self.options.adt_swift_tenant): raise RuntimeError('Incomplete swift credentials given') + # once swift credentials are given, the results will be published + # to a private container + self.swift_container = 'private-' + self.swift_container + + # check if all private PPAs have a fingerprint provided + # private PPAs need to follow the following pattern: + # user:token@team/name:fingerprint + for ppa in self.options.adt_ppas: + # TODO: write a test for this + if '@' in ppa and not re.match(r'^.+:.+@.+:.+$', ppa): + raise RuntimeError('Private PPA %s not following required format (user:token@team/name:fingerprint)', ppa) + import swiftclient if '/v2.0' in self.options.adt_swift_auth_url: @@ -214,7 +228,7 @@ class AutopkgtestPolicy(BasePolicy): else: auth_version = '1' - self.logger.info('Creating an authenticated swift connection for user %s', self.adt_swift_user) + self.logger.info('Creating an authenticated swift connection for user %s', self.options.adt_swift_user) self.swift_conn = swiftclient.Connection( authurl=self.options.adt_swift_auth_url, user=self.options.adt_swift_user,