Interactive results for support bundle kinds
@@ -99,6 +99,7 @@ func runTroubleshoot(v *viper.Viper, arg string) error {
s := spin.New()
finishedCh := make(chan bool, 1)
progressChan := make(chan interface{}, 0) // non-zero buffer can result in missed messages
+ isFinishedChClosed := false
go func() {
currentDir := ""
for {
@@ -124,7 +125,9 @@ func runTroubleshoot(v *viper.Viper, arg string) error {
}
}()
defer func() {
+ if !isFinishedChClosed {
close(finishedCh)
+ }
}()
archivePath, err := runCollectors(v, supportBundleSpec.Spec.Collectors, additionalRedactors, progressChan)
@@ -180,6 +183,18 @@ func runTroubleshoot(v *viper.Viper, arg string) error {
c.Printf("%s\r * Failed to analyze support bundle: %v\n", cursor.ClearEntireLine(), err)
}
+ interactive := isatty.IsTerminal(os.Stdout.Fd())
+
+ if interactive {
+ close(finishedCh) // this removes the spinner
+ isFinishedChClosed = true
+
+ if err := showInteractiveResults(analyzeResults); err != nil {
+ interactive = false
+ }
+ }
+
+ if !interactive {
data := convert.FromAnalyzerResult(analyzeResults)
formatted, err := json.MarshalIndent(data, "", " ")
if err != nil {
@@ -189,6 +204,7 @@ func runTroubleshoot(v *viper.Viper, arg string) error {
fmt.Printf("%s", formatted)
}
+ }
if !fileUploaded {
msg := archivePath
