Skip to content

Commit

Permalink
Fixes #717: run should not add --requires if --no-deps
Browse files Browse the repository at this point in the history
Signed-off-by: Emanuel Rietveld <[email protected]>
  • Loading branch information
bailsman committed Jan 15, 2025
1 parent 60ac5e4 commit e76a38d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
6 changes: 3 additions & 3 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ def get_net_args_from_networks(compose, cnt):
return net_args


async def container_to_args(compose, cnt, detached=True):
async def container_to_args(compose, cnt, detached=True, no_deps=False):
# TODO: double check -e , --add-host, -v, --read-only
dirname = compose.dirname
pod = cnt.get("pod", "")
Expand All @@ -1035,7 +1035,7 @@ async def container_to_args(compose, cnt, detached=True):
deps = []
for dep_srv in cnt.get("_deps", []):
deps.extend(compose.container_names_by_service.get(dep_srv.name, []))
if deps:
if deps and not no_deps:
deps_csv = ",".join(deps)
podman_args.append(f"--requires={deps_csv}")
sec = norm_as_list(cnt.get("security_opt"))
Expand Down Expand Up @@ -2915,7 +2915,7 @@ async def compose_run(compose, args):

compose_run_update_container_from_args(compose, cnt, args)
# run podman
podman_args = await container_to_args(compose, cnt, args.detach)
podman_args = await container_to_args(compose, cnt, args.detach, args.no_deps)
if not args.detach:
podman_args.insert(1, "-i")
if args.rm:
Expand Down
25 changes: 25 additions & 0 deletions tests/integration/test_podman_compose_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,31 @@ def test_deps(self):
"down",
])

def test_run_nodeps(self):
try:
output, error = self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"run",
"--rm",
"--no-deps",
"sleep",
"/bin/sh",
"-c",
"wget -O - http://web:8000/hosts || echo Failed to connect",
])
self.assertNotIn(b"HTTP request sent, awaiting response... 200 OK", output)
self.assertNotIn(b"deps_web_1", output)
self.assertIn(b"Failed to connect", output)
finally:
self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"down",
])


class TestComposeConditionalDeps(unittest.TestCase, RunSubprocessMixin):
def test_deps_succeeds(self):
Expand Down

0 comments on commit e76a38d

Please sign in to comment.