From b929791680c2c804b3f2b8631e01f1a86e55b5eb Mon Sep 17 00:00:00 2001 From: berg <13611129507@163.com> Date: Tue, 11 Feb 2020 16:28:56 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E8=BF=87=E6=BB=A4=E6=8E=89=E4=B8=8D?= =?UTF-8?q?=E5=90=88=E8=A7=84=E8=8C=83=E7=9A=84labels=20#351?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bcs-scheduler/src/manager/store/etcd/store.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bcs-mesos/bcs-scheduler/src/manager/store/etcd/store.go b/bcs-mesos/bcs-scheduler/src/manager/store/etcd/store.go index d45f24cac3..5ec607b461 100644 --- a/bcs-mesos/bcs-scheduler/src/manager/store/etcd/store.go +++ b/bcs-mesos/bcs-scheduler/src/manager/store/etcd/store.go @@ -71,6 +71,9 @@ type managerStore struct { k8sClient *kubernetes.Clientset extensionClient *extensionClientset.Clientset + regkey *regexp.Regexp + regvalue *regexp.Regexp + wg sync.WaitGroup ctx context.Context cancel context.CancelFunc @@ -269,6 +272,10 @@ func NewEtcdStore(kubeconfig string) (store.Store, error) { extensionClient: extensionClient, } + //init object labels regexp + m.regkey, _ = regexp.Compile("^([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$") + m.regvalue, _ = regexp.Compile("^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$") + //init clientset crds err = m.initKubeCrd() if err != nil { @@ -342,14 +349,13 @@ func (store *managerStore) filterSpecialLabels(oriLabels map[string]string) map[ if oriLabels == nil { return nil } - regkey, _ := regexp.Compile("^([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$") - regvalue, _ := regexp.Compile("^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$") + labels := make(map[string]string) for k, v := range oriLabels { - if !regkey.MatchString(k) { + if !store.regkey.MatchString(k) { continue } - if !regvalue.MatchString(v) { + if !store.regvalue.MatchString(v) { continue }