Do not hardcode output stream in pkg/output

Co-authored-by: Ahmed AbouZaid <6760103+aabouzaid@users.noreply.github.com>
This commit is contained in:
Yann Hamon 2023-04-23 13:34:45 +02:00
parent 8bc9f42f39
commit d038bf8840
2 changed files with 3 additions and 5 deletions

View file

@ -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
}

View file

@ -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