Skip to content

Commit

Permalink
Turn on SilenceErrors and SilenceUsage to prevent Cobra from messing …
Browse files Browse the repository at this point in the history
…up the stderr output

Signed-off-by: Richard Wall <richard.wall@venafi.com>
  • Loading branch information
wallrj committed Oct 30, 2024
1 parent 0a622bb commit 4438c98
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (

"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/jetstack/preflight/pkg/logs"
)

// rootCmd represents the base command when called without any subcommands
Expand All @@ -17,6 +19,14 @@ var rootCmd = &cobra.Command{
configuration checks using Open Policy Agent (OPA).
Preflight checks are bundled into Packages`,
// SilenceErrors and SilenceUsage prevents this command or any sub-command
// from printing arbitrary text to stderr.
// Why? To ensure that each line of output can be parsed as a single message
// for consumption by logging agents such as fluentd.
// Usage information is still available on stdout with the `-h` and `--help`
// flags.
SilenceErrors: true,
SilenceUsage: true,
}

func init() {
Expand Down

0 comments on commit 4438c98

Please sign in to comment.