From 91d316ff1f4683071c6e9d47be71a952ce3904fd Mon Sep 17 00:00:00 2001 From: Evgeniy Timokhov Date: Sat, 9 Sep 2023 23:18:43 +0100 Subject: [PATCH] Added handling `pid` option Fixes #554 Signed-off-by: Evgeniy Timokhov --- podman_compose.py | 2 ++ pytests/test_container_to_args.py | 22 ++++++++++++++++++++++ tests/pid/docker-compose.yml | 6 ++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/pid/docker-compose.yml diff --git a/podman_compose.py b/podman_compose.py index e3ee67b..702a5d6 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -981,6 +981,8 @@ async def container_to_args(compose, cnt, detached=True): podman_args.append("--tty") if cnt.get("privileged", None): podman_args.append("--privileged") + if cnt.get("pid", None): + podman_args.extend(["--pid", cnt["pid"]]) pull_policy = cnt.get("pull_policy", None) if pull_policy is not None and pull_policy != "build": podman_args.extend(["--pull", pull_policy]) diff --git a/pytests/test_container_to_args.py b/pytests/test_container_to_args.py index e5026f3..1146c3d 100644 --- a/pytests/test_container_to_args.py +++ b/pytests/test_container_to_args.py @@ -130,3 +130,25 @@ async def test_sysctl_wrong_type(self): with self.assertRaises(TypeError): cnt["sysctls"] = wrong_type await container_to_args(c, cnt) + + async def test_pid(self): + c = create_compose_mock() + cnt = get_minimal_container() + + cnt["pid"] = "host" + + args = await container_to_args(c, cnt) + self.assertEqual( + args, + [ + "--name=project_name_service_name1", + "-d", + "--net", + "", + "--network-alias", + "service_name", + "--pid", + "host", + "busybox", + ], + ) diff --git a/tests/pid/docker-compose.yml b/tests/pid/docker-compose.yml new file mode 100644 index 0000000..3abf657 --- /dev/null +++ b/tests/pid/docker-compose.yml @@ -0,0 +1,6 @@ +version: "3" +services: + serv: + image: busybox + pid: host + command: sh -c "ps all"