diff --git a/cmd/minishift/cmd/util/util.go b/cmd/minishift/cmd/util/util.go index c76900f7da..4214c14b66 100644 --- a/cmd/minishift/cmd/util/util.go +++ b/cmd/minishift/cmd/util/util.go @@ -105,8 +105,8 @@ func IsValidProfile(profileName string) bool { return false } -// IsValidProfileName return true if profile name follow ^\w+[\w+-]+$ +// IsValidProfileName return true if profile name follow ^[a-zA-Z0-9]+[\w+-]*$ func IsValidProfileName(profileName string) bool { - rr := regexp.MustCompile(`^\w+[\w+-]+$`) + rr := regexp.MustCompile(`^[a-zA-Z0-9]+[\w+-]*$`) return rr.MatchString(profileName) } diff --git a/cmd/minishift/cmd/util/util_test.go b/cmd/minishift/cmd/util/util_test.go index 1dc9e377c3..c174b6ce2b 100644 --- a/cmd/minishift/cmd/util/util_test.go +++ b/cmd/minishift/cmd/util/util_test.go @@ -32,6 +32,12 @@ func TestIsValidProfileName(t *testing.T) { {"foo_123", true}, {"foo@123", false}, {"", false}, + {"a", true}, + {"a-", true}, + {"a_", true}, + {"1", true}, + {"_", false}, + {"-", false}, {"-foo", false}, {"--hell", false}, {"foo-123", true}} diff --git a/docs/source/using/profiles.adoc b/docs/source/using/profiles.adoc index 7694dece8c..9f41a60f94 100644 --- a/docs/source/using/profiles.adoc +++ b/docs/source/using/profiles.adoc @@ -31,10 +31,8 @@ There are two ways to create a new profile. [NOTE] ==== -Profile name can only consist of alphanumeric characters and *-* as a separator, for example: - -- foo, bar123, demo-profile and 1stProfile are considered as valid profile names. -- $foo, bar#@, profile@123 are invalid profile names. +Profile name can only consist of alphanumeric characters. +The use of underscore ( *_* ) and hyphen ( *-* ) are allowed as separator. ==== === Using the `--profile` Flag