Skip to content

Commit e392fd4

Browse files
committed
Support ps arguments for containerTop()
1 parent 24578f4 commit e392fd4

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/Client.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,14 @@ public function containerInspect($container)
116116
/**
117117
* List processes running inside the container id
118118
*
119-
* @param string $container container ID
119+
* @param string $container container ID
120+
* @param string|null $ps_args (optional) ps arguments to use (e.g. aux)
120121
* @return Promise Promise<array>
121122
* @link https://docs.docker.com/reference/api/docker_remote_api_v1.15/#list-processes-running-inside-a-container
122123
*/
123-
public function containerTop($container)
124+
public function containerTop($container, $ps_args = null)
124125
{
125-
return $this->browser->get($this->url('/containers/%s/top', $container))->then(array($this->parser, 'expectJson'));
126+
return $this->browser->get($this->url('/containers/%s/top?ps_args=%s', $container, $ps_args))->then(array($this->parser, 'expectJson'));
126127
}
127128

128129
/**

tests/ClientTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ public function testContainerInspect()
5252
$this->expectPromiseResolveWith($json, $this->client->containerInspect(123));
5353
}
5454

55-
public function testContainerTop()
55+
public function testContainerTopArgs()
5656
{
5757
$json = array();
58-
$this->expectRequestFlow('get', '/containers/123/top', $this->createResponseJson($json), 'expectJson');
58+
$this->expectRequestFlow('get', '/containers/123/top?ps_args=aux', $this->createResponseJson($json), 'expectJson');
5959

60-
$this->expectPromiseResolveWith($json, $this->client->containerTop(123));
60+
$this->expectPromiseResolveWith($json, $this->client->containerTop(123, 'aux'));
6161
}
6262

6363
public function testContainerChanges()

0 commit comments

Comments
 (0)