Merge ~pelpsi/launchpad:requestProxyToken-function-refactor into launchpad:master

Proposed by Simone Pelosi
Status: Merged
Approved by: Simone Pelosi
Approved revision: 8e9905ab332dfc46745c671af63d6659d6bc35aa
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pelpsi/launchpad:requestProxyToken-function-refactor
Merge into: launchpad:master
Diff against target: 37 lines (+4/-16)
1 file modified
lib/lp/buildmaster/builderproxy.py (+4/-16)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+462145@code.launchpad.net

Commit message

Refactor _requestProxyToken to be aligned with _requestFetchServiceSession

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Ideally, the creation of the new function and the refactoring would have been done before the new feature work in https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/461721, but this is straightforward enough.

review: Approve
Revision history for this message
Ines Almeida (ines-almeida) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/buildmaster/builderproxy.py b/lib/lp/buildmaster/builderproxy.py
2index 1ac121f..75e049f 100644
3--- a/lib/lp/buildmaster/builderproxy.py
4+++ b/lib/lp/buildmaster/builderproxy.py
5@@ -1,4 +1,4 @@
6-# Copyright 2015-2021 Canonical Ltd. This software is licensed under the
7+# Copyright 2015-2024 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9
10 """Builder proxy support.
11@@ -84,23 +84,11 @@ class BuilderProxyMixin:
12
13 @defer.inlineCallbacks
14 def _requestProxyToken(self):
15- admin_username = _get_proxy_config(
16+ admin_username = _get_value_from_config(
17 "builder_proxy_auth_api_admin_username"
18 )
19- if not admin_username:
20- raise CannotBuild(
21- "builder_proxy_auth_api_admin_username is not configured."
22- )
23- secret = _get_proxy_config("builder_proxy_auth_api_admin_secret")
24- if not secret:
25- raise CannotBuild(
26- "builder_proxy_auth_api_admin_secret is not configured."
27- )
28- url = _get_proxy_config("builder_proxy_auth_api_endpoint")
29- if not secret:
30- raise CannotBuild(
31- "builder_proxy_auth_api_endpoint is not configured."
32- )
33+ secret = _get_value_from_config("builder_proxy_auth_api_admin_secret")
34+ url = _get_value_from_config("builder_proxy_auth_api_endpoint")
35 timestamp = int(time.time())
36 proxy_username = "{build_id}-{timestamp}".format(
37 build_id=self.build.build_cookie, timestamp=timestamp

Subscribers

People subscribed via source and target branches

to status/vote changes: