diff --git a/cmd/minikube/cmd/root.go b/cmd/minikube/cmd/root.go index 49aac3af5f..a29886b5b2 100644 --- a/cmd/minikube/cmd/root.go +++ b/cmd/minikube/cmd/root.go @@ -66,7 +66,7 @@ var RootCmd = &cobra.Command{ } } userName := viper.GetString(config.UserFlag) - if !config.UserNameValid(userName) { + if !validateUsername(userName) { out.WarningT("User name '{{.username}}' is not valid", out.V{"username": userName}) exit.Message(reason.Usage, "User name must be 60 chars or less.") } @@ -291,3 +291,7 @@ func addToPath(dir string) { klog.Infof("Updating PATH: %s", dir) os.Setenv("PATH", new) } + +func validateUsername(name string) bool { + return len(name) <= 60 +} diff --git a/pkg/minikube/config/user.go b/pkg/minikube/config/user.go deleted file mode 100644 index 3cbd340874..0000000000 --- a/pkg/minikube/config/user.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package config - -// UserNameValid checks if the user name is valid. -func UserNameValid(name string) bool { - return len(name) <= 60 -} diff --git a/pkg/minikube/config/user_test.go b/pkg/minikube/config/user_test.go deleted file mode 100644 index 57994fed5c..0000000000 --- a/pkg/minikube/config/user_test.go +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package config - -import ( - "strings" - "testing" -) - -func TestUser(t *testing.T) { - t.Run("Length", func(t *testing.T) { - tests := []struct { - in string - want bool - }{ - {strings.Repeat("a", 60), true}, - {strings.Repeat("a", 61), false}, - } - - for _, tt := range tests { - got := UserNameValid(tt.in) - - if got != tt.want { - t.Errorf("UserNameValid(%q, length: %d) = %t; want %t", tt.in, len(tt.in), got, tt.want) - } - } - }) -}