diff --git a/cmd/minikube/cmd/config/configure.go b/cmd/minikube/cmd/config/configure.go index 5c75c1454b3f..1fee633c73cc 100644 --- a/cmd/minikube/cmd/config/configure.go +++ b/cmd/minikube/cmd/config/configure.go @@ -61,7 +61,7 @@ var addonsConfigureCmd = &cobra.Command{ awsAccessKey = AskForStaticValue("-- Enter AWS Secret Access Key: ") awsRegion = AskForStaticValue("-- Enter AWS Region: ") awsAccount = AskForStaticValue("-- Enter 12 digit AWS Account ID: ") - awsRole = AskForStaticValue("-- (Optional) Enter ARN of AWS role to assume: ") + awsRole = AskForStaticValueOptional("-- (Optional) Enter ARN of AWS role to assume: ") } enableGCR := AskForYesNoConfirmation("\nDo you want to enable Google Container Registry?", posResponses, negResponses) diff --git a/cmd/minikube/cmd/config/prompt.go b/cmd/minikube/cmd/config/prompt.go index 7d34d285d553..7cdaa7f5afa4 100644 --- a/cmd/minikube/cmd/config/prompt.go +++ b/cmd/minikube/cmd/config/prompt.go @@ -19,11 +19,12 @@ package config import ( "bufio" "fmt" - "golang.org/x/crypto/ssh/terminal" "io" "log" "os" "strings" + + "golang.org/x/crypto/ssh/terminal" ) // AskForYesNoConfirmation asks the user for confirmation. A user must type in "yes" or "no" and @@ -59,24 +60,36 @@ func AskForStaticValue(s string) string { reader := bufio.NewReader(os.Stdin) for { - fmt.Printf("%s", s) - - response, err := reader.ReadString('\n') - if err != nil { - log.Fatal(err) - } - - response = strings.TrimSpace(response) + response := getStaticValue(reader, s) // Can't have zero length if len(response) == 0 { fmt.Println("--Error, please enter a value:") - return AskForStaticValue(s) + continue } return response } } +// AskForStaticValueOptional asks for a optional single value to enter, can just skip enter +func AskForStaticValueOptional(s string) string { + reader := bufio.NewReader(os.Stdin) + + return getStaticValue(reader, s) +} + +func getStaticValue(reader *bufio.Reader, s string) string { + fmt.Printf("%s", s) + + response, err := reader.ReadString('\n') + if err != nil { + log.Fatal(err) + } + + response = strings.TrimSpace(response) + return response +} + func concealableAskForStaticValue(readWriter io.ReadWriter, promptString string, hidden bool) (string, error) { for { var (