From 810b3cbf786690c28ea662b593044ee22f313898 Mon Sep 17 00:00:00 2001 From: Salah Aldeen Al Saleh Date: Tue, 23 Mar 2021 18:01:39 -0700 Subject: [PATCH] support non-interactive mode in support bundle (#340) * support non-interactive mode in support bundle --- cmd/troubleshoot/cli/root.go | 1 + cmd/troubleshoot/cli/run.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/troubleshoot/cli/root.go b/cmd/troubleshoot/cli/root.go index 70c7d95d..cf466ec1 100644 --- a/cmd/troubleshoot/cli/root.go +++ b/cmd/troubleshoot/cli/root.go @@ -38,6 +38,7 @@ from a server that can be used to assist when troubleshooting a Kubernetes clust cmd.Flags().StringSlice("redactors", []string{}, "names of the additional redactors to use") cmd.Flags().Bool("redact", true, "enable/disable default redactions") + cmd.Flags().Bool("interactive", true, "enable/disable interactive mode") cmd.Flags().Bool("collect-without-permissions", false, "always generate a support bundle, even if it some require additional permissions") cmd.Flags().String("since-time", "", "force pod logs collectors to return logs after a specific date (RFC3339)") cmd.Flags().String("since", "", "force pod logs collectors to return logs newer than a relative duration like 5s, 2m, or 3h.") diff --git a/cmd/troubleshoot/cli/run.go b/cmd/troubleshoot/cli/run.go index 137e6b5e..d569e05e 100644 --- a/cmd/troubleshoot/cli/run.go +++ b/cmd/troubleshoot/cli/run.go @@ -200,7 +200,7 @@ 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()) + interactive := v.GetBool("interactive") && isatty.IsTerminal(os.Stdout.Fd()) if interactive { close(finishedCh) // this removes the spinner