From d038bf8840b4cdd4cc2c993fb8daaad410da1cdb Mon Sep 17 00:00:00 2001 From: Yann Hamon Date: Sun, 23 Apr 2023 13:34:45 +0200 Subject: [PATCH] Do not hardcode output stream in pkg/output Co-authored-by: Ahmed AbouZaid <6760103+aabouzaid@users.noreply.github.com> --- cmd/kubeconform/main.go | 2 +- pkg/output/output.go | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/kubeconform/main.go b/cmd/kubeconform/main.go index e8a93e4e..b8ed16b1 100644 --- a/cmd/kubeconform/main.go +++ b/cmd/kubeconform/main.go @@ -94,7 +94,7 @@ func realMain() int { } var o output.Output - if o, err = output.New(cfg.OutputFormat, cfg.Summary, useStdin, cfg.Verbose); err != nil { + if o, err = output.New(os.Stdout, cfg.OutputFormat, cfg.Summary, useStdin, cfg.Verbose); err != nil { fmt.Fprintln(os.Stderr, err) return 1 } diff --git a/pkg/output/output.go b/pkg/output/output.go index aaefc74e..9f85f1d9 100644 --- a/pkg/output/output.go +++ b/pkg/output/output.go @@ -2,7 +2,7 @@ package output import ( "fmt" - "os" + "io" "github.com/yannh/kubeconform/pkg/validator" ) @@ -12,9 +12,7 @@ type Output interface { Flush() error } -func New(outputFormat string, printSummary, isStdin, verbose bool) (Output, error) { - w := os.Stdout - +func New(w io.Writer, outputFormat string, printSummary, isStdin, verbose bool) (Output, error) { switch { case outputFormat == "json": return jsonOutput(w, printSummary, isStdin, verbose), nil