mirror of
https://github.com/yannh/kubeconform.git
synced 2026-07-04 02:19:31 +00:00
loggers take an io.writer
This commit is contained in:
parent
9f6965d10f
commit
9b129d021a
4 changed files with 28 additions and 20 deletions
|
|
@ -3,6 +3,7 @@ package output
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
type result struct {
|
||||
|
|
@ -14,14 +15,16 @@ type result struct {
|
|||
}
|
||||
|
||||
type jsono struct {
|
||||
w io.Writer
|
||||
withSummary bool
|
||||
verbose bool
|
||||
results []result
|
||||
nValid, nInvalid, nErrors, nSkipped int
|
||||
}
|
||||
|
||||
func JSON(withSummary bool, quiet bool) Output {
|
||||
func JSON(w io.Writer, withSummary bool, quiet bool) Output {
|
||||
return &jsono{
|
||||
w: w,
|
||||
withSummary: withSummary,
|
||||
verbose: quiet,
|
||||
results: []result{},
|
||||
|
|
@ -99,8 +102,8 @@ func (o *jsono) Flush() {
|
|||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("error print results: %s", err)
|
||||
fmt.Fprintf(o.w, "error print results: %s", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("%s\n", res)
|
||||
fmt.Fprintf(o.w, "%s\n", res)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue