@@ -5,11 +5,13 @@ import (
55 "os"
66 "strings"
77
8+ "github.com/go-logr/logr"
89 troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
910 "github.com/replicatedhq/troubleshoot/pkg/k8sutil"
1011 "github.com/replicatedhq/troubleshoot/pkg/logger"
1112 "github.com/spf13/cobra"
1213 "github.com/spf13/viper"
14+ "k8s.io/klog/v2"
1315)
1416
1517func RootCmd () * cobra.Command {
@@ -21,7 +23,12 @@ func RootCmd() *cobra.Command {
2123from a server that can be used to assist when troubleshooting a Kubernetes cluster.` ,
2224 SilenceUsage : true ,
2325 PreRun : func (cmd * cobra.Command , args []string ) {
24- viper .BindPFlags (cmd .Flags ())
26+ v := viper .GetViper ()
27+ v .BindPFlags (cmd .Flags ())
28+
29+ if ! v .GetBool ("debug" ) {
30+ klog .SetLogger (logr .Discard ())
31+ }
2532 },
2633 RunE : func (cmd * cobra.Command , args []string ) error {
2734 v := viper .GetViper ()
@@ -43,6 +50,7 @@ from a server that can be used to assist when troubleshooting a Kubernetes clust
4350 cmd .Flags ().String ("since-time" , "" , "force pod logs collectors to return logs after a specific date (RFC3339)" )
4451 cmd .Flags ().String ("since" , "" , "force pod logs collectors to return logs newer than a relative duration like 5s, 2m, or 3h." )
4552 cmd .Flags ().StringP ("output" , "o" , "" , "specify the output file path for the support bundle" )
53+ cmd .Flags ().Bool ("debug" , false , "enable debug logging" )
4654
4755 // hidden in favor of the `insecure-skip-tls-verify` flag
4856 cmd .Flags ().Bool ("allow-insecure-connections" , false , "when set, do not verify TLS certs when retrieving spec and reporting results" )
0 commit comments