From bf1c60dc5d6722083201d8f7af793032c63cadd9 Mon Sep 17 00:00:00 2001 From: Gabriel de Marmiesse Date: Sat, 9 Mar 2024 08:37:13 +0100 Subject: [PATCH] :sparkles: docker.compose.down() can take str as service arg (#562) --- python_on_whales/components/compose/cli_wrapper.py | 10 ++++++---- tests/python_on_whales/components/test_compose.py | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/python_on_whales/components/compose/cli_wrapper.py b/python_on_whales/components/compose/cli_wrapper.py index 3983c2c7..5571a350 100644 --- a/python_on_whales/components/compose/cli_wrapper.py +++ b/python_on_whales/components/compose/cli_wrapper.py @@ -24,7 +24,7 @@ class ComposeCLI(DockerCLICaller): @overload def build( self, - services: Optional[List[str]] = ..., + services: Union[List[str], str, None] = ..., build_args: Dict[str, str] = ..., cache: bool = ..., progress: Optional[str] = ..., @@ -38,7 +38,7 @@ def build( @overload def build( self, - services: Optional[List[str]] = ..., + services: Union[List[str], str, None] = ..., build_args: Dict[str, str] = ..., cache: bool = ..., progress: Optional[str] = ..., @@ -51,7 +51,7 @@ def build( def build( self, - services: Optional[List[str]] = None, + services: Union[List[str], str, None] = None, build_args: Dict[str, str] = {}, cache: bool = True, progress: Optional[str] = None, @@ -99,7 +99,9 @@ def build( if services == []: return elif services is not None: - full_cmd += services + full_cmd += to_list(services) + else: + pass # passing nothing means all services are built if stream_logs: return stream_stdout_and_stderr(full_cmd) else: diff --git a/tests/python_on_whales/components/test_compose.py b/tests/python_on_whales/components/test_compose.py index 65c5faec..f225cc39 100644 --- a/tests/python_on_whales/components/test_compose.py +++ b/tests/python_on_whales/components/test_compose.py @@ -122,6 +122,7 @@ def test_compose_project_name(): def test_docker_compose_build(): docker.compose.build() docker.compose.build(["my_service"]) + docker.compose.build("my_service") docker.image.remove("some_random_image")