diff --git a/cmd/preflight/cli/run.go b/cmd/preflight/cli/run.go index 065e435c..dc0a25ec 100644 --- a/cmd/preflight/cli/run.go +++ b/cmd/preflight/cli/run.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "net/http" "os" + "os/signal" "strings" "time" @@ -28,6 +29,14 @@ func runPreflights(v *viper.Viper, arg string) error { fmt.Print(cursor.Hide()) defer fmt.Print(cursor.Show()) + go func() { + signalChan := make(chan os.Signal, 1) + signal.Notify(signalChan, os.Interrupt) + <-signalChan + fmt.Print(cursor.Show()) + os.Exit(0) + }() + var preflightContent []byte var err error if strings.HasPrefix(arg, "secret/") { diff --git a/cmd/troubleshoot/cli/run.go b/cmd/troubleshoot/cli/run.go index 379758a0..14ec51eb 100644 --- a/cmd/troubleshoot/cli/run.go +++ b/cmd/troubleshoot/cli/run.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "net/http" + "os/signal" "net/url" "os" @@ -33,6 +34,14 @@ func runTroubleshoot(v *viper.Viper, arg string) error { fmt.Print(cursor.Hide()) defer fmt.Print(cursor.Show()) + go func() { + signalChan := make(chan os.Signal, 1) + signal.Notify(signalChan, os.Interrupt) + <-signalChan + fmt.Print(cursor.Show()) + os.Exit(0) + }() + k8sConfig, err := k8sutil.GetRESTConfig() if err != nil { return errors.Wrap(err, "failed to convert kube flags to rest config")