Load the image tarball, and return its digest.
(tarball_path: Path | None = None)
| 317 | |
| 318 | |
| 319 | def load_image_tarball(tarball_path: Path | None = None) -> str: |
| 320 | """Load the image tarball, and return its digest.""" |
| 321 | log.info("Installing Dangerzone container image...") |
| 322 | podman = init_podman_command() |
| 323 | if not tarball_path: |
| 324 | tarball_path = get_resource_path("container.tar") |
| 325 | try: |
| 326 | res = podman.run(["load", "-i", str(tarball_path)], capture_output=True) |
| 327 | assert isinstance(res, str) |
| 328 | # The stdout of the above command is usually 'Loaded image: sha256:<digest>' |
| 329 | # we can get the image digest by grabbing the last part of stdout. |
| 330 | return res.split()[-1] |
| 331 | except subprocess.CalledProcessError as e: |
| 332 | if e.stderr: |
| 333 | error = e.stderr.decode() |
| 334 | else: |
| 335 | error = "No output" |
| 336 | raise errors.ImageInstallationException( |
| 337 | f"Could not install container image: {error}" |
| 338 | ) |
| 339 | |
| 340 | |
| 341 | def tag_image_by_digest(digest: str, tag: str) -> None: |
nothing calls this directly
no test coverage detected