Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add validations --image-repository inputs #10760

Merged
merged 2 commits into from
Mar 10, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,10 @@ func validateFlags(cmd *cobra.Command, drvName string) {
validateListenAddress(viper.GetString(listenAddress))
}

if cmd.Flags().Changed(imageRepository) {
validateImageRepository(viper.GetString(imageRepository))
}

if cmd.Flags().Changed(containerRuntime) {
runtime := strings.ToLower(viper.GetString(containerRuntime))

Expand Down Expand Up @@ -1208,6 +1212,18 @@ func validateRegistryMirror() {
}
}

// This function validates if the --image-repository
// args match the format of registry.cn-hangzhou.aliyuncs.com/google_containers
func validateImageRepository(imagRepo string) {
yxxhero marked this conversation as resolved.
Show resolved Hide resolved
URL, err := url.Parse(imagRepo)
if err != nil {
klog.Errorln("Error Parsing URL: ", err)
}
if URL.Scheme != "" || strings.HasSuffix(URL.Path, "/") {
exit.Message(reason.Usage, "Sorry, the url provided with the --image-repository flag is invalid: {{.url}}", out.V{"url": imagRepo})
yxxhero marked this conversation as resolved.
Show resolved Hide resolved
}
}

// This function validates if the --listen-address
// match the format 0.0.0.0
func validateListenAddress(listenAddr string) {
Expand Down