diff --git a/pkg/backingstore/backingstore.go b/pkg/backingstore/backingstore.go index b3d9b2250d..de1fd33e91 100644 --- a/pkg/backingstore/backingstore.go +++ b/pkg/backingstore/backingstore.go @@ -395,7 +395,9 @@ func createCommon(cmd *cobra.Command, args []string, storeType nbv1.StoreType, p log.Printf("Found a Secret in the system with the same credentials (%s)", suggestedSecret.Name) log.Printf("Note that using more then one secret with the same credentials is not supported") log.Printf("do you want to use it for this Backingstore? y/n") - fmt.Scanln(&decision) + if _, err := fmt.Scanln(&decision); err != nil { + log.Fatalf(`❌ Invalid input, please select y/n`) + } if strings.ToLower(decision) == "y" { log.Printf("Will use %s as the Backingstore %s Secret", suggestedSecret.Name, backStore.Name) err := util.SetBackingStoreSecretRef(backStore, &corev1.SecretReference{ @@ -407,8 +409,6 @@ func createCommon(cmd *cobra.Command, args []string, storeType nbv1.StoreType, p } } else if strings.ToLower(decision) == "n" { log.Fatalf("Not creating Backingstore") - } else { - log.Fatalf(`❌ Invalid input, please select y/n`) } } diff --git a/pkg/install/install.go b/pkg/install/install.go index 38b3b82df8..f9e7db0c25 100644 --- a/pkg/install/install.go +++ b/pkg/install/install.go @@ -149,19 +149,21 @@ func RunUninstall(cmd *cobra.Command, args []string) { if cleanup { var decision string + log.Printf("--cleanup removes the CRDs and affecting all noobaa instances, are you sure? y/n ") for { - log.Printf("--cleanup removes the CRDs and affecting all noobaa instances, are you sure? y/n ") - fmt.Scanln(&decision) + if _, err := fmt.Scanln(&decision); err != nil { + log.Printf(`are you sure? y/n`) + } if decision == "y" { log.Printf("Will remove CRD (cluster scope)") break } else if decision == "n" { - return + log.Printf("Will not uninstall as remove CRD (cluster scope) was declined.") + log.Fatalf("In order to uninstall agree to remove CRD or remove the --cleanup flag.") } } } - system.RunSystemVersionsStatus(cmd, args) log.Printf("Namespace: %s", options.Namespace) log.Printf("") diff --git a/pkg/namespacestore/namespacestore.go b/pkg/namespacestore/namespacestore.go index 01378656e8..87b7038a2e 100644 --- a/pkg/namespacestore/namespacestore.go +++ b/pkg/namespacestore/namespacestore.go @@ -370,7 +370,9 @@ func createCommon(cmd *cobra.Command, args []string, storeType nbv1.NSType, popu log.Printf("Found a Secret in the system with the same credentials (%s)", suggestedSecret.Name) log.Printf("Note that using more then one secret with the same credentials is not supported") log.Printf("do you want to use it for this Namespacestore? y/n") - fmt.Scanln(&decision) + if _, err := fmt.Scanln(&decision); err != nil { + log.Fatalf(`❌ Invalid input, please select y/n`) + } if strings.ToLower(decision) == "y" { log.Printf("Will use %s as the Namespacestore Secret", suggestedSecret.Name) err := util.SetNamespaceStoreSecretRef(namespaceStore, &corev1.SecretReference{ @@ -382,8 +384,6 @@ func createCommon(cmd *cobra.Command, args []string, storeType nbv1.NSType, popu } } else if strings.ToLower(decision) == "n" { log.Fatalf("Not creating Namespacestore") - } else { - log.Fatalf(`❌ Invalid input, please select y/n`) } } diff --git a/pkg/noobaaaccount/noobaaaccount.go b/pkg/noobaaaccount/noobaaaccount.go index 322354cc29..efd331d3e0 100644 --- a/pkg/noobaaaccount/noobaaaccount.go +++ b/pkg/noobaaaccount/noobaaaccount.go @@ -343,7 +343,9 @@ func RunRegenerate(cmd *cobra.Command, args []string) { log.Printf("are you sure? y/n") for { - fmt.Scanln(&decision) + if _, err := fmt.Scanln(&decision); err != nil { + log.Printf(`are you sure? y/n`) + } if decision == "y" { break } else if decision == "n" { diff --git a/pkg/obc/obc.go b/pkg/obc/obc.go index 102e8b1c33..5e2de80c85 100644 --- a/pkg/obc/obc.go +++ b/pkg/obc/obc.go @@ -265,7 +265,9 @@ func RunRegenerate(cmd *cobra.Command, args []string) { log.Printf("are you sure? y/n") for { - fmt.Scanln(&decision) + if _, err := fmt.Scanln(&decision); err != nil { + log.Printf(`are you sure? y/n`) + } if decision == "y" { break } else if decision == "n" {