Skip to content

Commit

Permalink
hotfix: cluster create argument value validation (#1256)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommartensen authored Apr 11, 2024
1 parent aeffea6 commit e4a81a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/infractl/cluster/utils/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func ValidateParameterArgument(parts []string) error {
if value == "" {
return errors.New("value is empty")
}
match, err = regexp.MatchString(`^[a-zA-Z0-9:?/.-_]+$`, value)
match, err = regexp.MatchString(`^[a-zA-Z0-9:\/\?._-]+$`, value)
if err != nil {
return err
}
Expand Down
15 changes: 15 additions & 0 deletions cmd/infractl/cluster/utils/validate_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package utils

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestValidateParameterArgument(t *testing.T) {
err := ValidateParameterArgument([]string{"machine-type", "e2-medium"})
assert.NoError(t, err, "no error expected")

err = ValidateParameterArgument([]string{"container-type", "container_d"})
assert.NoError(t, err, "no error expected")
}

0 comments on commit e4a81a3

Please sign in to comment.