Skip to content

Commit

Permalink
Merge pull request #207 from briceburg/briceburg/filter-by-object
Browse files Browse the repository at this point in the history
add test and examples for filtering by map
  • Loading branch information
apocas committed Jan 5, 2016
2 parents 385964d + c97a353 commit 7b41d96
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/listContainers.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ var opts = {
"filters": '{"label": ["staging","env=green"]}'
};

// maps are also supported (** requires docker-modem 0.3+ **)
opts["filters"] = {
"label": [
"staging",
"env=green"
]
};

docker.listContainers(opts, function(err, containers) {
console.log('Containers labeled staging + env=green : ' + containers.length);
});
13 changes: 13 additions & 0 deletions test/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,5 +573,18 @@ describe("#docker", function() {
done();
});
});

it("should query containers filtering by map of valued labels", function(done){
docker.listContainers({
"limit": 3,
"filters": {
"label": ["dockerode-test-label","dockerode-test-value-label=assigned"]
}
}, function(err, data){
expect(data.length).to.equal(1);
done();
});
});

});
});

0 comments on commit 7b41d96

Please sign in to comment.