Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Split string command and entrypoint values into argument lists after interpolation, matching Compose semantics.
3 changes: 3 additions & 0 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,9 @@ def normalize_service_final(service: dict[str, Any], project_dir: str) -> dict[s
if not isinstance(service["build"], dict):
service["build"] = {}
service["build"]["context"] = context
for key in ("command", "entrypoint"):
if isinstance(service.get(key), str):
service[key] = shlex.split(service[key])
return service


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def test_compose_file_from_dotenv(self) -> None:
out.decode("utf-8"),
'services:\n'
' dotenv-service:\n'
' command: echo "from-dotenv"\n'
' command:\n'
' - echo\n'
' - from-dotenv\n'
' image: nopush/podman-compose-test\n'
'\n',
)
Expand All @@ -47,7 +49,9 @@ def test_compose_file_from_explicit_env_file(self) -> None:
out.decode("utf-8"),
'services:\n'
' explicit-env-service:\n'
' command: echo "from-explicit-env"\n'
' command:\n'
' - echo\n'
' - from-explicit-env\n'
' image: nopush/podman-compose-test\n'
'\n',
)
Expand All @@ -70,7 +74,9 @@ def test_explicit_f_overrides_compose_file_from_dotenv(self) -> None:
out.decode("utf-8"),
'services:\n'
' explicit-service:\n'
' command: echo "explicit"\n'
' command:\n'
' - echo\n'
' - explicit\n'
' image: nopush/podman-compose-test\n'
'\n',
)
Expand All @@ -88,7 +94,9 @@ def test_env_var_compose_file_takes_precedence_over_dotenv(self) -> None:
out.decode("utf-8"),
'services:\n'
' var-service:\n'
' command: echo "var"\n'
' command:\n'
' - echo\n'
' - var\n'
' image: nopush/podman-compose-test\n'
'\n',
)
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/test_normalize_final_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ def test_normalize_service_final_returns_absolute_path_in_context(self, input, e
project_dir = cwd
self.assertEqual(normalize_service_final(input, project_dir), expected)

@parameterized.expand([
({"image": "busybox", "command": "sleep infinity"}, ["sleep", "infinity"], None),
({"image": "busybox", "command": ["sleep", "infinity"]}, ["sleep", "infinity"], None),
({"image": "busybox", "entrypoint": "/bin/sh -c"}, None, ["/bin/sh", "-c"]),
])
def test_normalize_service_final_splits_string_command(
self, input, expected_command, expected_entrypoint
):
# Tests that string [service.command] and [service.entrypoint] are split into
# lists after variable interpolation
actual = normalize_service_final(input, cwd)
self.assertEqual(actual.get("command"), expected_command)
self.assertEqual(actual.get("entrypoint"), expected_entrypoint)

@parameterized.expand(cases_simple_normalization)
def test_normalize_returns_absolute_path_in_context(self, input, expected):
project_dir = cwd
Expand Down
Loading