From ae35871efb3a05cc843795f338a1166c7fbaf7f7 Mon Sep 17 00:00:00 2001 From: mahao Date: Mon, 4 Mar 2024 18:56:19 +0800 Subject: [PATCH] support image-repository contain numeric characters Signed-off-by: Allen --- cmd/minikube/cmd/start.go | 2 +- cmd/minikube/cmd/start_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index fc18fc314cf2..b9f5a7728cfc 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -1597,7 +1597,7 @@ func validateRegistryMirror() { // args match the format of registry.cn-hangzhou.aliyuncs.com/google_containers // also "[:]" func validateImageRepository(imageRepo string) (validImageRepo string) { - expression := regexp.MustCompile(`^(?:(\w+)\:\/\/)?([-a-zA-Z0-9]{1,}(?:\.[-a-zA-Z]{1,}){0,})(?:\:(\d+))?(\/.*)?$`) + expression := regexp.MustCompile(`^(?:(\w+)\:\/\/)?([-a-zA-Z0-9]{1,}(?:\.[-a-zA-Z0-9]{1,}){0,})(?:\:(\d+))?(\/.*)?$`) if strings.ToLower(imageRepo) == "auto" { imageRepo = "auto" diff --git a/cmd/minikube/cmd/start_test.go b/cmd/minikube/cmd/start_test.go index 7f11deaeff34..cf21d0dcf163 100644 --- a/cmd/minikube/cmd/start_test.go +++ b/cmd/minikube/cmd/start_test.go @@ -384,6 +384,18 @@ func TestValidateImageRepository(t *testing.T) { imageRepository: "registry.test.com:6666/google_containers", validImageRepository: "registry.test.com:6666/google_containers", }, + { + imageRepository: "registry.1test.com:6666/google_containers", + validImageRepository: "registry.1test.com:6666/google_containers", + }, + { + imageRepository: "registry.t1est.com:6666/google_containers", + validImageRepository: "registry.t1est.com:6666/google_containers", + }, + { + imageRepository: "registry.test1.com:6666/google_containers", + validImageRepository: "registry.test1.com:6666/google_containers", + }, } for _, test := range tests {