Support `--filter mode=global|replicated` for `docker service ls`

This fix tries to address the request in 31325 by adding
`--filter mode=global|replicated` to `docker service ls`.

As `docker service ls` has a `MODE` column by default, it is natural
to support `--filter mode=global|replicated` for `docker service ls`.

There are multiple ways to address the issue. One way is to pass
the filter of mode to SwarmKit, another way is to process the filter
of mode in the daemon.

This fix process the filter in the daemon.

Related docs has been updated.

An integration test has been added.

This fix fixes 31325.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang 2017-03-03 14:08:49 -08:00 committed by Tibor Vass
parent 6fe11272d3
commit d43b0f1269
1 changed files with 13 additions and 0 deletions

View File

@ -60,6 +60,7 @@ The currently supported filters are:
* [id](service_ls.md#id) * [id](service_ls.md#id)
* [label](service_ls.md#label) * [label](service_ls.md#label)
* [mode](service_ls.md#mode)
* [name](service_ls.md#name) * [name](service_ls.md#name)
#### id #### id
@ -98,6 +99,18 @@ ID NAME MODE REPLICAS IMAGE
74nzcxxjv6fq backend replicated 3/3 redis:3.0.6 74nzcxxjv6fq backend replicated 3/3 redis:3.0.6
``` ```
#### mode
The `mode` filter matches on the mode (either `replicated` or `global`) of a service.
The following filter matches only `global` services.
```bash
$ docker service ls --filter mode=global
ID NAME MODE REPLICAS IMAGE
w7y0v2yrn620 top global 1/1 busybox
```
#### name #### name
The `name` filter matches on all or part of a service's name. The `name` filter matches on all or part of a service's name.