Skip to content

Commit f82cf83

Browse files
fix(cmd) Fix proctype regex for scaling
This disallows upper case characters to match deis/controller checks.
1 parent 1f5e242 commit f82cf83

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

cmd/ps.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ func parseType(target string, appID string) (string, string) {
142142

143143
func parsePsTargets(targets []string) (map[string]int, error) {
144144
targetMap := make(map[string]int)
145-
regex := regexp.MustCompile(`^([a-zA-Z0-9]+(\-[a-zA-Z0-9]+)*)=([0-9]+)$`)
145+
regex := regexp.MustCompile(`^([a-z0-9]+(?:-[a-z0-9]+)*)=([0-9]+)$`)
146146
var err error
147147

148148
for _, target := range targets {
149149
if regex.MatchString(target) {
150150
captures := regex.FindStringSubmatch(target)
151-
targetMap[captures[1]], err = strconv.Atoi(captures[3])
151+
targetMap[captures[1]], err = strconv.Atoi(captures[2])
152152

153153
if err != nil {
154154
return nil, err

cmd/ps_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ func TestParsePsTargets(t *testing.T) {
119119
{[]string{"test"}, true, nil, "'test' does not match the pattern 'type=num', ex: web=2\n"},
120120
{[]string{"test=a"}, true, nil, "'test=a' does not match the pattern 'type=num', ex: web=2\n"},
121121
{[]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"},
122123
{[]string{"test=2"}, false, map[string]int{"test": 2}, ""},
123124
{[]string{"test-proc=2"}, false, map[string]int{"test-proc": 2}, ""},
124-
{[]string{"Test1=2"}, false, map[string]int{"Test1": 2}, ""},
125+
{[]string{"test1=2"}, false, map[string]int{"test1": 2}, ""},
125126
}
126127

127128
for _, check := range cases {

0 commit comments

Comments
 (0)