mirror of
https://github.com/containers/podman-compose.git
synced 2025-02-10 23:39:39 +01:00
Run should not add --requires if --no-deps.
Fixes #717. Signed-off-by: Emanuel Rietveld <e.j.rietveld@gmail.com>
This commit is contained in:
parent
48c6c38fcd
commit
8206cc3ea2
@ -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", "")
|
||||
@ -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"))
|
||||
@ -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:
|
||||
|
@ -35,6 +35,31 @@ class TestComposeBaseDeps(unittest.TestCase, RunSubprocessMixin):
|
||||
"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):
|
||||
|
Loading…
Reference in New Issue
Block a user