Skip to content

Commit

Permalink
Convert OciRuntimeBase.build_command from List -> Tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
dcermak committed Aug 21, 2024
1 parent 0a9b446 commit d15a7bc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Next Release

Breaking changes:

- change type of ``OciRuntimeBase.build_command`` from ``List[str]`` to
``Tuple[str, ...]``


Improvements and new features:

Expand Down
2 changes: 1 addition & 1 deletion pytest_container/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [])
Expand Down
9 changes: 5 additions & 4 deletions pytest_container/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)
Expand Down

0 comments on commit d15a7bc

Please sign in to comment.