sources(curl): set HTTP proxy through the environment

This commit is contained in:
Sanne Raymaekers 2024-04-05 17:30:30 +02:00
parent 98f5904181
commit b90a5027dc

View file

@ -146,6 +146,7 @@ class CurlSource(sources.SourceService):
secrets = desc.get("secrets") secrets = desc.get("secrets")
insecure = desc.get("insecure") insecure = desc.get("insecure")
url = self._quote_url(desc.get("url")) url = self._quote_url(desc.get("url"))
proxy = os.getenv("OSBUILD_SOURCES_CURL_PROXY")
# Download to a temporary sub cache until we have verified the checksum. Use a # Download to a temporary sub cache until we have verified the checksum. Use a
# subdirectory, so we avoid copying across block devices. # subdirectory, so we avoid copying across block devices.
with tempfile.TemporaryDirectory(prefix="osbuild-unverified-file-", dir=self.cache) as tmpdir: with tempfile.TemporaryDirectory(prefix="osbuild-unverified-file-", dir=self.cache) as tmpdir:
@ -162,6 +163,8 @@ class CurlSource(sources.SourceService):
"--location", "--location",
"--output", checksum, "--output", checksum,
] ]
if proxy:
curl_command.extend(["--proxy", proxy])
if secrets: if secrets:
if secrets.get('ssl_ca_cert'): if secrets.get('ssl_ca_cert'):
curl_command.extend(["--cacert", secrets.get('ssl_ca_cert')]) curl_command.extend(["--cacert", secrets.get('ssl_ca_cert')])