Skip to content

Commit 904bc49

Browse files
Himanshu Pandeymedyagh
Himanshu Pandey
authored andcommitted
Added validation for --registry-mirror flag
1 parent 17a407d commit 904bc49

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cmd/minikube/cmd/start.go

+21
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222
"io/ioutil"
2323
"net"
24+
"net/url"
2425
"os"
2526
"os/exec"
2627
"os/user"
@@ -397,6 +398,26 @@ func validateConfig() {
397398
exit.Usage("Sorry, the kubeadm.%s parameter is currently not supported by --extra-config", param)
398399
}
399400
}
401+
402+
validateRegistryMirror()
403+
}
404+
405+
// This function validates if the --registry-mirror
406+
//args match the format of http://localhost
407+
func validateRegistryMirror() {
408+
409+
if len(registryMirror) > 0 {
410+
for _, loc := range registryMirror {
411+
URL, err := url.Parse(loc)
412+
if err != nil {
413+
glog.Errorln("Error Parsing URL: ", err)
414+
}
415+
if (URL.Scheme != "http" && URL.Scheme != "https") || URL.Path != "" {
416+
exit.Usage("Sorry, url provided with --registry-mirror flag is invalid %q", loc)
417+
}
418+
419+
}
420+
}
400421
}
401422

402423
// doCacheBinaries caches Kubernetes binaries in the foreground

0 commit comments

Comments
 (0)