diff --git a/src/Client.php b/src/Client.php index 3fc69d4..1ffb192 100644 --- a/src/Client.php +++ b/src/Client.php @@ -807,16 +807,18 @@ public function containerAttachStream($container, $logs = false, $stream = false * Block until container id stops, then returns the exit code * * @param string $container container ID + * @param string $condition Wait until a container state reaches the given condition * @return PromiseInterface Promise `array('StatusCode' => 0)` (see link) * @link https://docs.docker.com/engine/api/v1.40/#operation/ContainerWait */ - public function containerWait($container) + public function containerWait($container, $condition = null) { return $this->browser->post( $this->uri->expand( - 'containers/{container}/wait', + 'containers/{container}/wait{?condition}', array( - 'container' => $container + 'container' => $container, + 'condition' => $condition ) ) )->then(array($this->parser, 'expectJson')); diff --git a/tests/ClientTest.php b/tests/ClientTest.php index e815ff1..8f3ff1b 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -268,6 +268,14 @@ public function testContainerWait() $this->expectPromiseResolveWith($json, $this->client->containerWait(123)); } + public function testContainerWaitConditionalNextExit() + { + $json = array(); + $this->expectRequestFlow('post', 'containers/123/wait?condition=next-exit', $this->createResponseJson($json), 'expectJson'); + + $this->expectPromiseResolveWith($json, $this->client->containerWait(123, 'next-exit')); + } + public function testContainerKill() { $this->expectRequestFlow('post', 'containers/123/kill', $this->createResponse(), 'expectEmpty');