Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Removes regexp checking of config namespaces in wmap
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
IRCody committed Oct 3, 2016
1 parent 7746a24 commit d969354
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
9 changes: 0 additions & 9 deletions scheduler/scheduler_test.go
Expand Up @@ -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())
Expand Down
14 changes: 0 additions & 14 deletions scheduler/wmap/wmap.go
Expand Up @@ -23,7 +23,6 @@ import (
"encoding/json"
"errors"
"fmt"
"regexp"
"strings"

yaml "gopkg.in/yaml.v2"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d969354

Please sign in to comment.