builder: add support for proxying requests to composer

We need koji-osbuild-builder to be able to connect to composer via a proxy
because koji builders in our internal deployment cannot reach
api.openshift.com directly. This commit adds a new option `proxy` to the
builder plugin config that controls whether a proxy is used to route all
requests to composer.
This commit is contained in:
Ondřej Budai 2022-04-21 21:47:10 +02:00 committed by Christian Kellner
parent dca6717568
commit d8c9332257
3 changed files with 130 additions and 1 deletions

View file

@ -469,6 +469,16 @@ class OSBuildImage(BaseTaskHandler):
self.client.http.verify = val
self.logger.debug("ssl verify: %s", val)
proxy = composer.get("proxy")
if proxy:
# route both http and https requests through the proxy
proxies = {
"http": proxy,
"https": proxy
}
self.client.http.proxies.update(proxies)
self.logger.debug("proxy: %s", proxy)
if "composer:oauth" in cfg:
oa = cfg["composer:oauth"]
client_id, client_secret = oa["client_id"], oa["client_secret"]