Merge pull request #1945 from jimmyxian/add-support-ps-node-filter

Add support ps node filter
This commit is contained in:
Victor Vieux 2016-03-11 13:09:49 -08:00
commit 63997816a5
2 changed files with 16 additions and 0 deletions

View File

@ -378,6 +378,9 @@ func getContainersJSON(c *context, w http.ResponseWriter, r *http.Request) {
if !filters.Match("status", container.Info.State.StateString()) { if !filters.Match("status", container.Info.State.StateString()) {
continue continue
} }
if !filters.Match("node", container.Engine.Name) {
continue
}
if len(filtExited) > 0 { if len(filtExited) > 0 {
shouldSkip := true shouldSkip := true

View File

@ -144,3 +144,16 @@ function teardown() {
[[ "$output" == *"$secondID"* ]] [[ "$output" == *"$secondID"* ]]
[[ "$output" != *"$thirdID"* ]] [[ "$output" != *"$thirdID"* ]]
} }
@test "docker ps --filter node" {
start_docker_with_busybox 2
swarm_manage
docker_swarm run --name c1 -e constraint:node==node-0 -d busybox:latest sleep 100
docker_swarm run --name c2 -e constraint:node==node-1 -d busybox:latest sleep 100
run docker_swarm ps --filter node=node-0
[ "$status" -eq 0 ]
[[ "${output}" == *"node-0/c1"* ]]
[[ "${output}" != *"node-1/c2"* ]]
}