From d9693541037b149cbdb55c7a75976ebabb439121 Mon Sep 17 00:00:00 2001 From: Cody Roseborough Date: Fri, 30 Sep 2016 15:49:23 -0700 Subject: [PATCH] Removes regexp checking of config namespaces in wmap Removes regexp checking of config namespaces in wamp when parsing task manifest. This regexp results in weird behavior where a nemespace for a metric can be allowed but the config for it is not. Removes test that seems to rely this behavior. --- scheduler/scheduler_test.go | 9 --------- scheduler/wmap/wmap.go | 14 -------------- 2 files changed, 23 deletions(-) diff --git a/scheduler/scheduler_test.go b/scheduler/scheduler_test.go index 1a67d2e57..e42ceeb51 100644 --- a/scheduler/scheduler_test.go +++ b/scheduler/scheduler_test.go @@ -217,15 +217,6 @@ func TestScheduler(t *testing.T) { }) - Convey("returns an error when wrong namespace is given wo workflowmap ", func() { - w.CollectNode.AddMetric("****/&&&", 3) - w.CollectNode.AddConfigItem("****/&&&", "username", "user") - _, err := s.CreateTask(schedule.NewSimpleSchedule(time.Second*1), w, false) - - So(len(err.Errors()), ShouldBeGreaterThan, 0) - - }) - // TODO NICK Convey("returns an error when a schedule does not validate", func() { s1 := New(GetDefaultConfig()) diff --git a/scheduler/wmap/wmap.go b/scheduler/wmap/wmap.go index cd10958fe..ee14b43ac 100644 --- a/scheduler/wmap/wmap.go +++ b/scheduler/wmap/wmap.go @@ -23,7 +23,6 @@ import ( "encoding/json" "errors" "fmt" - "regexp" "strings" yaml "gopkg.in/yaml.v2" @@ -242,10 +241,6 @@ func (c *CollectWorkflowMapNode) GetConfigTree() (*cdata.ConfigDataTree, error) // Iterate over config and attempt to convert into data nodes in the tree for ns_, cmap := range c.Config { - // Attempt to convert namespace string to proper namespace - if !isValidNamespaceString(ns_) { - return nil, errors.New(fmt.Sprintf("Invalid namespace: %v", ns_)) - } ns := strings.Split(ns_, "/")[1:] cdn, err := configtoConfigDataNode(cmap, ns_) if err != nil { @@ -460,15 +455,6 @@ func (m Metric) Version() int { return m.version } -func isValidNamespaceString(ns string) bool { - b, err := regexp.MatchString("^(/[a-z0-9]+)+$", ns) - if err != nil { - // Just safety in case regexp packages changes in some way to break this in the future. - panic(err) - } - return b -} - func configtoConfigDataNode(cmap map[string]interface{}, ns string) (*cdata.ConfigDataNode, error) { cdn := cdata.NewNode() for ck, cv := range cmap {