From 843a3880729a3b63c72d7ec06dcf2cb60a80a17c Mon Sep 17 00:00:00 2001 From: ZhuPeng Date: Mon, 4 Jan 2016 11:35:48 +0800 Subject: [PATCH] Add label selector work --- scale-demo/aggregator/aggregator.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scale-demo/aggregator/aggregator.go b/scale-demo/aggregator/aggregator.go index 161708819b..b8a6fbc7b8 100644 --- a/scale-demo/aggregator/aggregator.go +++ b/scale-demo/aggregator/aggregator.go @@ -101,7 +101,17 @@ func loadData() { fmt.Printf("Error creating client: %v", err) return } - pods, err := c.Pods("default").List(labels.Everything(), fields.Everything()) + var labelSelector labels.Selector + if *selector != "" { + labelSelector, err = labels.Parse(*selector) + if err != nil { + fmt.Printf("Parse label selector err: %v", err) + return + } + } else { + labelSelector = labels.Everything() + } + pods, err := c.Pods("default").List(labelSelector, fields.Everything()) if err != nil { fmt.Printf("Error getting pods: %v", err) return