Skip to content

Commit

Permalink
Make bundle validate subcommand respect verbosity
Browse files Browse the repository at this point in the history
This makes the bundle validate subcommand respect the verbosity level
by setting it directly in the logger that's actually used, and not in
the global logger as was done previously.

Closes: #3793
  • Loading branch information
JAORMX committed Aug 27, 2020
1 parent 6917885 commit 4327b78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
- Fixed CVE-2020-14040 by updating to `golang.org/x/text/0.3.3`. ([#3458](https://github.com/operator-framework/operator-sdk/pull/3458))
- The `scorecard` subcommand now removes existing pods if the `--wait-time` deadline is exceeded and `--skip-cleanup=false` (the default). Fixes [#3419](https://github.com/operator-framework/operator-sdk/issues/3419). ([#3526](https://github.com/operator-framework/operator-sdk/pull/3526))
- Fixed a bug in scorecard that caused tests to fail with permission errors when loading the bundle. ([#3428](https://github.com/operator-framework/operator-sdk/pull/3428))
- Fixed debug logging in the `bundle validate` subcommand of `operator-sdk` [#3793](https://github.com/operator-framework/operator-sdk/issues/3793). ([#3795](https://github.com/operator-framework/operator-sdk/pull/3795))

### Since v1.0.0-alpha.2

Expand Down
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)
}

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

0 comments on commit 4327b78

Please sign in to comment.