mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-11 14:09:21 +00:00
more nits
This commit is contained in:
parent
5ff2d1a037
commit
0ddf4e9a50
5 changed files with 16 additions and 15 deletions
6
main.go
6
main.go
|
|
@ -138,9 +138,9 @@ func (ap *arrayParam) Set(value string) error {
|
|||
func getLogger(outputFormat string, printSummary, quiet bool) (output.Output, error) {
|
||||
switch {
|
||||
case outputFormat == "text":
|
||||
return output.NewTextOutput(printSummary, quiet), nil
|
||||
return output.Text(printSummary, quiet), nil
|
||||
case outputFormat == "json":
|
||||
return output.NewJSONOutput(printSummary, quiet), nil
|
||||
return output.JSON(printSummary, quiet), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("-output must be text or json")
|
||||
}
|
||||
|
|
@ -230,7 +230,7 @@ func realMain() int {
|
|||
}
|
||||
}()
|
||||
|
||||
c := cache.NewSchemaCache()
|
||||
c := cache.New()
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < nWorkers; i++ {
|
||||
wg.Add(1)
|
||||
|
|
|
|||
2
pkg/cache/main.go
vendored
2
pkg/cache/main.go
vendored
|
|
@ -11,7 +11,7 @@ type SchemaCache struct {
|
|||
schemas map[string]*gojsonschema.Schema
|
||||
}
|
||||
|
||||
func NewSchemaCache() *SchemaCache {
|
||||
func New() *SchemaCache {
|
||||
return &SchemaCache{
|
||||
schemas: map[string]*gojsonschema.Schema{},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,15 +13,15 @@ type result struct {
|
|||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
type JSONOutput struct {
|
||||
type jsono struct {
|
||||
withSummary bool
|
||||
quiet bool
|
||||
results []result
|
||||
nValid, nInvalid, nErrors, nSkipped int
|
||||
}
|
||||
|
||||
func NewJSONOutput(withSummary bool, quiet bool) Output {
|
||||
return &JSONOutput{
|
||||
func JSON(withSummary bool, quiet bool) Output {
|
||||
return &jsono{
|
||||
withSummary: withSummary,
|
||||
quiet: quiet,
|
||||
results: []result{},
|
||||
|
|
@ -32,7 +32,7 @@ func NewJSONOutput(withSummary bool, quiet bool) Output {
|
|||
}
|
||||
}
|
||||
|
||||
func (o *JSONOutput) Write(filename, kind, version string, err error, skipped bool) {
|
||||
func (o *jsono) Write(filename, kind, version string, err error, skipped bool) {
|
||||
msg, st := "", ""
|
||||
|
||||
s := status(err, skipped)
|
||||
|
|
@ -59,7 +59,7 @@ func (o *JSONOutput) Write(filename, kind, version string, err error, skipped bo
|
|||
}
|
||||
}
|
||||
|
||||
func (o *JSONOutput) Flush() {
|
||||
func (o *jsono) Flush() {
|
||||
var err error
|
||||
var res []byte
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
VALID = iota
|
||||
_ = iota
|
||||
VALID
|
||||
INVALID
|
||||
ERROR
|
||||
SKIPPED
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
type TextOutput struct {
|
||||
type text struct {
|
||||
sync.Mutex
|
||||
withSummary bool
|
||||
quiet bool
|
||||
nValid, nInvalid, nErrors, nSkipped int
|
||||
}
|
||||
|
||||
func NewTextOutput(withSummary, quiet bool) Output {
|
||||
return &TextOutput{
|
||||
func Text(withSummary, quiet bool) Output {
|
||||
return &text{
|
||||
withSummary: withSummary,
|
||||
quiet: quiet,
|
||||
nValid: 0,
|
||||
|
|
@ -23,7 +23,7 @@ func NewTextOutput(withSummary, quiet bool) Output {
|
|||
}
|
||||
}
|
||||
|
||||
func (o *TextOutput) Write(filename, kind, version string, err error, skipped bool) {
|
||||
func (o *text) Write(filename, kind, version string, err error, skipped bool) {
|
||||
o.Lock()
|
||||
defer o.Unlock()
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ func (o *TextOutput) Write(filename, kind, version string, err error, skipped bo
|
|||
}
|
||||
}
|
||||
|
||||
func (o *TextOutput) Flush() {
|
||||
func (o *text) Flush() {
|
||||
if o.withSummary {
|
||||
fmt.Printf("Run summary - Valid: %d, Invalid: %d, Errors: %d Skipped: %d\n", o.nValid, o.nInvalid, o.nErrors, o.nSkipped)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue