From d15a7bcf29a2c1ae5f777467736be378ea5da271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Wed, 21 Aug 2024 12:10:50 +0200 Subject: [PATCH] Convert OciRuntimeBase.build_command from List -> Tuple --- CHANGELOG.rst | 3 +++ pytest_container/build.py | 2 +- pytest_container/runtime.py | 9 +++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8912fbe..eee1424 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,9 @@ Next Release Breaking changes: +- change type of ``OciRuntimeBase.build_command`` from ``List[str]`` to + ``Tuple[str, ...]`` + Improvements and new features: diff --git a/pytest_container/build.py b/pytest_container/build.py index 4dca9d5..22d2514 100644 --- a/pytest_container/build.py +++ b/pytest_container/build.py @@ -223,7 +223,7 @@ def run_build_step( with tempfile.TemporaryDirectory() as tmp_dir: iidfile = join(tmp_dir, str(uuid4())) cmd = ( - runtime.build_command + [*runtime.build_command] + (extra_build_args or []) + [f"--iidfile={iidfile}"] + (["--target", target] if target else []) diff --git a/pytest_container/runtime.py b/pytest_container/runtime.py index dd55a01..70ebea9 100644 --- a/pytest_container/runtime.py +++ b/pytest_container/runtime.py @@ -17,6 +17,7 @@ from typing import Callable from typing import List from typing import Optional +from typing import Tuple from typing import TYPE_CHECKING from typing import Union @@ -182,7 +183,7 @@ def __gt__(self, other: Any) -> bool: @dataclass(frozen=True) class _OciRuntimeBase: #: command that builds the Dockerfile in the current working directory - build_command: List[str] = field(default_factory=list) + build_command: Tuple[str, ...] = field(default_factory=tuple) #: the "main" binary of this runtime, e.g. podman or docker runner_binary: str = "" _runtime_functional: bool = False @@ -468,9 +469,9 @@ def _runtime_error_message() -> str: def __init__(self) -> None: super().__init__( build_command=( - ["buildah", "bud", "--layers", "--force-rm"] + ("buildah", "bud", "--layers", "--force-rm") if self._buildah_functional - else ["podman", "build", "--layers", "--force-rm"] + else ("podman", "build", "--layers", "--force-rm") ), runner_binary="podman", _runtime_functional=self._runtime_functional, @@ -571,7 +572,7 @@ def _runtime_error_message() -> str: def __init__(self) -> None: super().__init__( - build_command=["docker", "build", "--force-rm"], + build_command=("docker", "build", "--force-rm"), runner_binary="docker", _runtime_functional=self._runtime_functional, )