Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.23.0
toolchain go1.23.6

require (
github.com/go-logr/logr v1.4.2
github.com/google/cel-go v0.17.8
github.com/google/go-cmp v0.6.0
github.com/onsi/ginkgo/v2 v2.21.0
Expand All @@ -13,12 +14,12 @@ require (
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
k8s.io/klog/v2 v2.140.0
)

require (
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc=
k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0=
23 changes: 23 additions & 0 deletions pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package cmd

import (
"os"

"github.com/spf13/cobra"
"k8s.io/klog/v2"

"github.com/openshift-eng/openshift-tests-extension/pkg/cmd/cmdimages"
"github.com/openshift-eng/openshift-tests-extension/pkg/cmd/cmdinfo"
Expand All @@ -11,6 +14,26 @@ import (
"github.com/openshift-eng/openshift-tests-extension/pkg/extension"
)

func init() {
// Configure klog to write to stderr instead of stdout BEFORE any commands run.
// This prevents klog warnings from corrupting JSON output during test listing.
//
// Background:
// - The 'list tests' command outputs JSON to stdout for consumption by CI systems
// - klog defaults to writing to stdout, which can include warnings from imported packages
// - When klog warnings appear in stdout, they corrupt the JSON stream with messages like:
// "W0327 12:34:56.123456 12345 warnings.go:70] deprecation warning"
// - This causes JSON parsers to fail with: "invalid character 'W' looking for beginning of value"
//
// Solution:
// - Redirect all klog output to stderr, keeping stdout clean for structured output
// - This is consistent with how pkg/ginkgo/util.go configures GinkgoWriter to stderr
// - In CI environments: stdout = structured data (JSON), stderr = logs/diagnostics
//
// See: https://github.com/openshift/cluster-authentication-operator/pull/857
klog.SetOutput(os.Stderr)
}

func DefaultExtensionCommands(registry *extension.Registry) []*cobra.Command {
return []*cobra.Command{
cmdrun.NewRunSuiteCommand(registry),
Expand Down
17 changes: 17 additions & 0 deletions vendor/k8s.io/klog/v2/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions vendor/k8s.io/klog/v2/.golangci.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/k8s.io/klog/v2/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

191 changes: 191 additions & 0 deletions vendor/k8s.io/klog/v2/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions vendor/k8s.io/klog/v2/OWNERS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading