diff --git a/cmd/infractl/cluster/utils/validate.go b/cmd/infractl/cluster/utils/validate.go index 79838af1e..1f4f110d8 100644 --- a/cmd/infractl/cluster/utils/validate.go +++ b/cmd/infractl/cluster/utils/validate.go @@ -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 } diff --git a/cmd/infractl/cluster/utils/validate_test.go b/cmd/infractl/cluster/utils/validate_test.go new file mode 100644 index 000000000..c165f3e74 --- /dev/null +++ b/cmd/infractl/cluster/utils/validate_test.go @@ -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") +}