From 514ce73391d065136a2cdfe9f0348dfe1bcc5c43 Mon Sep 17 00:00:00 2001 From: Anshul Pundir Date: Thu, 16 Aug 2018 16:29:33 -0700 Subject: [PATCH] Changes to cluster/filter, swagger.yaml, version-history.md for filtering on node labels. Signed-off-by: Anshul Pundir Signed-off-by: Sebastiaan van Stijn --- api/swagger.yaml | 1 + daemon/cluster/filters.go | 2 ++ docs/api/version-history.md | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/api/swagger.yaml b/api/swagger.yaml index 3906899050..0462d02618 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -8609,6 +8609,7 @@ paths: - `label=` - `membership=`(`accepted`|`pending`)` - `name=` + - `node.label=` - `role=`(`manager`|`worker`)` type: "string" tags: ["Node"] diff --git a/daemon/cluster/filters.go b/daemon/cluster/filters.go index 15469f907d..9a3180b838 100644 --- a/daemon/cluster/filters.go +++ b/daemon/cluster/filters.go @@ -16,6 +16,7 @@ func newListNodesFilters(filter filters.Args) (*swarmapi.ListNodesRequest_Filter "label": true, "role": true, "membership": true, + "node.label": true, } if err := filter.Validate(accepted); err != nil { return nil, err @@ -24,6 +25,7 @@ func newListNodesFilters(filter filters.Args) (*swarmapi.ListNodesRequest_Filter NamePrefixes: filter.Get("name"), IDPrefixes: filter.Get("id"), Labels: runconfigopts.ConvertKVStringsToMap(filter.Get("label")), + NodeLabels: runconfigopts.ConvertKVStringsToMap(filter.Get("node.label")), } for _, r := range filter.Get("role") { diff --git a/docs/api/version-history.md b/docs/api/version-history.md index 6f0083e90e..b91e5954f5 100644 --- a/docs/api/version-history.md +++ b/docs/api/version-history.md @@ -26,6 +26,10 @@ keywords: "API, Docker, rcli, REST, documentation" * `POST /swarm/init` now accepts a `DefaultAddrPool` property to set global scope default address pool * `POST /swarm/init` now accepts a `SubnetSize` property to set global scope networks by giving the length of the subnet masks for every such network +* `GET /nodes` now supports a filter type `node.label` filter to filter nodes based + on the node.label. The format of the label filter is `node.label=`/`node.label==` + to return those with the specified labels, or `node.label!=`/`node.label!==` + to return those without the specified labels. ## V1.38 API changes