Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 4b916e2

Browse files
authored
Made podman preferred backend (#22)
1 parent ba7c47e commit 4b916e2

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

Diff for: README.rst

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ Molecule Containers is designed to be a **drop-in replacement for the existing
2121
Docker and Podman drivers**, one that can transparently pick whichever backend
2222
is found.
2323

24-
Please note that this driver is currently in its **early stage of
25-
development**, do not even try to use it in production. Just raise a PR if you
26-
have a bugfix for it.
24+
The driver preference is defined by
25+
``MOLECULE_CONTAINERS_BACKEND=podman,docker`` and you can easily switch between
26+
the two by setting this variable.
27+
28+
Keep in mind that if executable is not found, the driver will fallback to
29+
first option in the list and likely fail later.
2730

2831
.. _get-involved:
2932

Diff for: molecule_containers/driver.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,13 @@
99

1010
_logger = logger.get_logger(__name__)
1111

12-
# Temporary logic to determine which backend driver should be loaded.
13-
# podman is used as fallback default.
14-
driver = os.environ.get("MOLECULE_CONTAINERS_BACKEND", "")
15-
if not driver:
16-
if "DOCKER_HOST" in os.environ:
17-
driver = "docker"
18-
elif "CONTAINER_HOST" in os.environ:
19-
driver = "podman"
20-
else:
21-
if shutil.which("docker"):
22-
driver = "docker"
23-
else:
24-
driver = "podman"
12+
# Preference logic for picking backend driver to be used.
13+
drivers = os.environ.get("MOLECULE_CONTAINERS_BACKEND", "podman,docker").split(",")
14+
for driver in drivers:
15+
if shutil.which(driver):
16+
break
17+
else:
18+
driver = drivers[0]
2519

2620
# Logic for picking backend is subject to change.
2721
if driver == "docker":

0 commit comments

Comments
 (0)