Skip to content

Commit

Permalink
Added validation for --registry-mirror flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Himanshu Pandey committed May 28, 2019
1 parent dcb1033 commit c557daf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -437,6 +438,8 @@ 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 @@ -755,3 +758,16 @@ 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 c557daf

Please sign in to comment.