Skip to content

Commit e76a38d

Browse files
committed
Fixes #717: run should not add --requires if --no-deps
Signed-off-by: Emanuel Rietveld <[email protected]>
1 parent 60ac5e4 commit e76a38d

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

podman_compose.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ def get_net_args_from_networks(compose, cnt):
10201020
return net_args
10211021

10221022

1023-
async def container_to_args(compose, cnt, detached=True):
1023+
async def container_to_args(compose, cnt, detached=True, no_deps=False):
10241024
# TODO: double check -e , --add-host, -v, --read-only
10251025
dirname = compose.dirname
10261026
pod = cnt.get("pod", "")
@@ -1035,7 +1035,7 @@ async def container_to_args(compose, cnt, detached=True):
10351035
deps = []
10361036
for dep_srv in cnt.get("_deps", []):
10371037
deps.extend(compose.container_names_by_service.get(dep_srv.name, []))
1038-
if deps:
1038+
if deps and not no_deps:
10391039
deps_csv = ",".join(deps)
10401040
podman_args.append(f"--requires={deps_csv}")
10411041
sec = norm_as_list(cnt.get("security_opt"))
@@ -2915,7 +2915,7 @@ async def compose_run(compose, args):
29152915

29162916
compose_run_update_container_from_args(compose, cnt, args)
29172917
# run podman
2918-
podman_args = await container_to_args(compose, cnt, args.detach)
2918+
podman_args = await container_to_args(compose, cnt, args.detach, args.no_deps)
29192919
if not args.detach:
29202920
podman_args.insert(1, "-i")
29212921
if args.rm:

tests/integration/test_podman_compose_deps.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,31 @@ def test_deps(self):
3535
"down",
3636
])
3737

38+
def test_run_nodeps(self):
39+
try:
40+
output, error = self.run_subprocess_assert_returncode([
41+
podman_compose_path(),
42+
"-f",
43+
compose_yaml_path(),
44+
"run",
45+
"--rm",
46+
"--no-deps",
47+
"sleep",
48+
"/bin/sh",
49+
"-c",
50+
"wget -O - http://web:8000/hosts || echo Failed to connect",
51+
])
52+
self.assertNotIn(b"HTTP request sent, awaiting response... 200 OK", output)
53+
self.assertNotIn(b"deps_web_1", output)
54+
self.assertIn(b"Failed to connect", output)
55+
finally:
56+
self.run_subprocess_assert_returncode([
57+
podman_compose_path(),
58+
"-f",
59+
compose_yaml_path(),
60+
"down",
61+
])
62+
3863

3964
class TestComposeConditionalDeps(unittest.TestCase, RunSubprocessMixin):
4065
def test_deps_succeeds(self):

0 commit comments

Comments
 (0)