Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make bundle validate subcommand respect verbosity #3795

Merged
merged 2 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/fragments/bundle-validate-verbose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
entries:
- description: Fixed debug logging in the `bundle validate` subcommand of `operator-sdk`
kind: "bugfix"
breaking: false
7 changes: 3 additions & 4 deletions internal/cmd/operator-sdk/bundle/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,14 @@ func makeValidateCmd() *cobra.Command {
Use: "validate",
Short: "Validate an operator bundle",
RunE: func(cmd *cobra.Command, args []string) (err error) {
if viper.GetBool(flags.VerboseOpt) {
log.SetLevel(log.DebugLevel)
}

// Always print non-output logs to stderr as to not pollute actual command output.
// Note that it allows the JSON result be redirected to the Stdout. E.g
// if we run the command with `| jq . > result.json` the command will print just the logs
// and the file will have only the JSON result.
logger := log.NewEntry(internal.NewLoggerTo(os.Stderr))
if viper.GetBool(flags.VerboseOpt) {
logger.Logger.SetLevel(log.DebugLevel)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be possible add the unit test to ensure it in validate_test.go?


if err = c.validate(args); err != nil {
return fmt.Errorf("invalid command args: %v", err)
Expand Down