We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 2dddbe1 + f82cf83 commit 006a03dCopy full SHA for 006a03d
4 files changed
cmd/limits.go
@@ -145,7 +145,7 @@ func parseLimits(limits []string) (map[string]interface{}, error) {
145
}
146
147
func parseLimit(limit string) (string, string, error) {
148
- regex := regexp.MustCompile("^([A-z]+)=(([0-9]+[bkmgBKMG]{1,2}|[0-9.]{1,5}|[0-9.]{1,5}m?)(/([0-9]+[bkmgBKMG]{1,2}|[0-9.]{1,5}|[0-9.]{1,5}m?}))?)$")
+ regex := regexp.MustCompile("^([a-z0-9]+(?:-[a-z0-9]+)*)=(([0-9]+[bkmgBKMG]{1,2}|[0-9.]{1,5}|[0-9.]{1,5}m?)(/([0-9]+[bkmgBKMG]{1,2}|[0-9.]{1,5}|[0-9.]{1,5}m?}))?)$")
149
150
if !regex.MatchString(limit) {
151
return "", "", fmt.Errorf(`%s doesn't fit format type=#unit or type=# or type=#/#
cmd/limits_test.go
@@ -36,12 +36,18 @@ Examples: web=2G worker=500M db=1G/2G`
36
{"web=200m/400m", "web", "200m/400m", false, ""},
37
{"web=0.2/0.4", "web", "0.2/0.4", false, ""},
38
{"web=.2/.4", "web", ".2/.4", false, ""},
39
+ {"web1=2G", "web1", "2G", false, ""},
40
+ {"web-server=2G", "web-server", "2G", false, ""},
41
+ {"web-server1=2G", "web-server1", "2G", false, ""},
42
{"=1", "", "", true, "=1" + errorHint},
43
{"web=", "", "", true, "web=" + errorHint},
44
{"1=", "", "", true, "1=" + errorHint},
45
{"web=G", "", "", true, "web=G" + errorHint},
46
{"web=/", "", "", true, "web=/" + errorHint},
47
{"web=/1", "", "", true, "web=/1" + errorHint},
48
+ {"web-=2G", "", "", true, "web-=2G" + errorHint},
49
+ {"-web=2G", "", "", true, "-web=2G" + errorHint},
50
+ {"Web=2G", "", "", true, "Web=2G" + errorHint},
51
52
53
for _, check := range cases {
cmd/ps.go
@@ -142,13 +142,13 @@ func parseType(target string, appID string) (string, string) {
142
143
func parsePsTargets(targets []string) (map[string]int, error) {
144
targetMap := make(map[string]int)
- regex := regexp.MustCompile(`^([a-zA-Z0-9]+(\-[a-zA-Z0-9]+)*)=([0-9]+)$`)
+ regex := regexp.MustCompile(`^([a-z0-9]+(?:-[a-z0-9]+)*)=([0-9]+)$`)
var err error
for _, target := range targets {
if regex.MatchString(target) {
captures := regex.FindStringSubmatch(target)
- targetMap[captures[1]], err = strconv.Atoi(captures[3])
+ targetMap[captures[1]], err = strconv.Atoi(captures[2])
152
153
if err != nil {
154
return nil, err
cmd/ps_test.go
@@ -119,9 +119,10 @@ func TestParsePsTargets(t *testing.T) {
119
{[]string{"test"}, true, nil, "'test' does not match the pattern 'type=num', ex: web=2\n"},
120
{[]string{"test=a"}, true, nil, "'test=a' does not match the pattern 'type=num', ex: web=2\n"},
121
{[]string{"test="}, true, nil, "'test=' does not match the pattern 'type=num', ex: web=2\n"},
122
+ {[]string{"Test=2"}, true, nil, "'Test=2' does not match the pattern 'type=num', ex: web=2\n"},
123
{[]string{"test=2"}, false, map[string]int{"test": 2}, ""},
124
{[]string{"test-proc=2"}, false, map[string]int{"test-proc": 2}, ""},
- {[]string{"Test1=2"}, false, map[string]int{"Test1": 2}, ""},
125
+ {[]string{"test1=2"}, false, map[string]int{"test1": 2}, ""},
126
127
128
0 commit comments