Skip to content

Commit

Permalink
WIP: docker-friendly runtime choice
Browse files Browse the repository at this point in the history
  • Loading branch information
dcermak committed Jan 30, 2024
1 parent a922c97 commit ac94f76
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pytest_container/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,15 +825,21 @@ def get_selected_runtime() -> OciRuntimeBase:
podman_exists = LOCALHOST.exists("podman") and LOCALHOST.exists("buildah")
docker_exists = LOCALHOST.exists("docker")

runtime_choice = getenv("CONTAINER_RUNTIME", "podman").lower()
if runtime_choice not in ("podman", "docker"):
runtime_choice = getenv("CONTAINER_RUNTIME", None)
if runtime_choice is not None and runtime_choice.lower() not in (
"podman",
"docker",
):
raise ValueError(f"Invalid CONTAINER_RUNTIME {runtime_choice}")

if runtime_choice == "podman" and podman_exists:
runtime_choice = runtime_choice and runtime_choice.lower() or None
if runtime_choice in ("podman", None) and podman_exists:
return PodmanRuntime()
if runtime_choice == "docker" and docker_exists:

if runtime_choice in ("docker", None) and docker_exists:
return DockerRuntime()

runtime_choice = runtime_choice or "(podman or docker)"
raise ValueError(
"Selected runtime " + runtime_choice + " does not exist on the system"
)

0 comments on commit ac94f76

Please sign in to comment.