From 93e267c5ae94bc63cf0ca21ac0c49d632cab5db0 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Mon, 8 Nov 2021 17:16:00 -0800 Subject: [PATCH] Allow custom cert for ingress to be overwritten --- cmd/minikube/cmd/config/configure.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd/minikube/cmd/config/configure.go b/cmd/minikube/cmd/config/configure.go index 9dfa7a1630..c85019edfd 100644 --- a/cmd/minikube/cmd/config/configure.go +++ b/cmd/minikube/cmd/config/configure.go @@ -32,6 +32,9 @@ import ( "k8s.io/minikube/pkg/minikube/style" ) +var posResponses = []string{"yes", "y"} +var negResponses = []string{"no", "n"} + var addonsConfigureCmd = &cobra.Command{ Use: "configure ADDON_NAME", Short: "Configures the addon w/ADDON_NAME within minikube (example: minikube addons configure registry-creds). For a list of available addons use: minikube addons list", @@ -45,8 +48,6 @@ var addonsConfigureCmd = &cobra.Command{ // allows for additional prompting of information when enabling addons switch addon { case "registry-creds": - posResponses := []string{"yes", "y"} - negResponses := []string{"no", "n"} // Default values awsAccessID := "changeme" @@ -220,10 +221,16 @@ var addonsConfigureCmd = &cobra.Command{ return format.MatchString(s) } - if cfg.KubernetesConfig.CustomIngressCert == "" { - cfg.KubernetesConfig.CustomIngressCert = AskForStaticValidatedValue("-- Enter custom cert(format is \"namespace/secret\"): ", validator) + customCert := AskForStaticValidatedValue("-- Enter custom cert(format is \"namespace/secret\"): ", validator) + if cfg.KubernetesConfig.CustomIngressCert != "" { + overwrite := AskForYesNoConfirmation("A custom cert for ingress has already been set. Do you want overwrite it?", posResponses, negResponses) + if !overwrite { + break + } } + cfg.KubernetesConfig.CustomIngressCert = customCert + if err := config.SaveProfile(profile, cfg); err != nil { out.ErrT(style.Fatal, "Failed to save config {{.profile}}", out.V{"profile": profile}) }