source/skopeo: use subprocess.check_output

Use `subprocess.check_output` instead of `run(..., capture_output=True)`
since the latter only got added in Python 3.7 and our codebase needs to
be compatible with 3.6 due to RHEL 8.x.
This commit is contained in:
Christian Kellner 2022-07-13 17:33:54 +02:00
parent 3fd864e5a9
commit 4647140808

View file

@ -102,10 +102,8 @@ class SkopeoSource(sources.SourceService):
# Verify that the digest supplied downloaded the correct container image id.
# The image id is the digest of the config, but skopeo can' currently
# get the config id, only the full config, so we checksum it ourselves.
res = subprocess.run(["skopeo", "inspect", "--raw", "--config", destination],
capture_output=True,
check=True)
downloaded_id = "sha256:" + hashlib.sha256(res.stdout).hexdigest()
res = subprocess.check_output(["skopeo", "inspect", "--raw", "--config", destination])
downloaded_id = "sha256:" + hashlib.sha256(res).hexdigest()
if downloaded_id != image_id:
raise RuntimeError(
f"Downloaded image {imagename}@{digest} has a id of {downloaded_id}, but expected {image_id}")