Skip to content

Commit

Permalink
Moved the code to validateConfig()
Browse files Browse the repository at this point in the history
  • Loading branch information
Himanshu Pandey committed May 28, 2019
1 parent c557daf commit bc0a272
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,18 @@ func validateConfig() {
exit.Usage("Sorry, the kubeadm.%s parameter is currently not supported by --extra-config", param)
}
}

// This validates if the --registry-mirror args
// match the format of http://localhost
urlRe := regexp.MustCompile(`^http(s{0,1}):\/\/(.+?)`)
if len(registryMirror) > 0 {
for _, loc := range registryMirror {
if !urlRe.MatchString(loc) {
exit.WithCode(exit.Failure, "url provided with --registry-mirror flag is invalid %q", loc)
}
}
}

}

// doCacheBinaries caches Kubernetes binaries in the foreground
Expand Down Expand Up @@ -438,8 +450,6 @@ func generateConfig(cmd *cobra.Command, k8sVersion string) (cfg.Config, error) {
console.OutStyle("success", "using image repository %s", repository)
}

validateRegistryMirror(registryMirror)

cfg := cfg.Config{
MachineConfig: cfg.MachineConfig{
MinikubeISO: viper.GetString(isoURL),
Expand Down Expand Up @@ -758,16 +768,3 @@ func saveConfig(clusterConfig cfg.Config) error {
}
return nil
}

// This function validates if the --registry--mirror args
// match the format of http://localhost
func validateRegistryMirror(registryMirror []string) {
urlRe := regexp.MustCompile(`http:\/\/(.+?)`)
if len(registryMirror) > 0 {
for _, loc := range registryMirror {
if !urlRe.MatchString(loc) {
exit.WithCode(exit.Failure, "url provided with --registry-mirror flag is invalid %q", loc)
}
}
}
}

0 comments on commit bc0a272

Please sign in to comment.