mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-17 08:57:02 +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) {
|
func getLogger(outputFormat string, printSummary, quiet bool) (output.Output, error) {
|
||||||
switch {
|
switch {
|
||||||
case outputFormat == "text":
|
case outputFormat == "text":
|
||||||
return output.NewTextOutput(printSummary, quiet), nil
|
return output.Text(printSummary, quiet), nil
|
||||||
case outputFormat == "json":
|
case outputFormat == "json":
|
||||||
return output.NewJSONOutput(printSummary, quiet), nil
|
return output.JSON(printSummary, quiet), nil
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("-output must be text or json")
|
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
|
var wg sync.WaitGroup
|
||||||
for i := 0; i < nWorkers; i++ {
|
for i := 0; i < nWorkers; i++ {
|
||||||
wg.Add(1)
|
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
|
schemas map[string]*gojsonschema.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSchemaCache() *SchemaCache {
|
func New() *SchemaCache {
|
||||||
return &SchemaCache{
|
return &SchemaCache{
|
||||||
schemas: map[string]*gojsonschema.Schema{},
|
schemas: map[string]*gojsonschema.Schema{},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,15 @@ type result struct {
|
||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type JSONOutput struct {
|
type jsono struct {
|
||||||
withSummary bool
|
withSummary bool
|
||||||
quiet bool
|
quiet bool
|
||||||
results []result
|
results []result
|
||||||
nValid, nInvalid, nErrors, nSkipped int
|
nValid, nInvalid, nErrors, nSkipped int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewJSONOutput(withSummary bool, quiet bool) Output {
|
func JSON(withSummary bool, quiet bool) Output {
|
||||||
return &JSONOutput{
|
return &jsono{
|
||||||
withSummary: withSummary,
|
withSummary: withSummary,
|
||||||
quiet: quiet,
|
quiet: quiet,
|
||||||
results: []result{},
|
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 := "", ""
|
msg, st := "", ""
|
||||||
|
|
||||||
s := status(err, skipped)
|
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 err error
|
||||||
var res []byte
|
var res []byte
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VALID = iota
|
_ = iota
|
||||||
|
VALID
|
||||||
INVALID
|
INVALID
|
||||||
ERROR
|
ERROR
|
||||||
SKIPPED
|
SKIPPED
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,15 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TextOutput struct {
|
type text struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
withSummary bool
|
withSummary bool
|
||||||
quiet bool
|
quiet bool
|
||||||
nValid, nInvalid, nErrors, nSkipped int
|
nValid, nInvalid, nErrors, nSkipped int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTextOutput(withSummary, quiet bool) Output {
|
func Text(withSummary, quiet bool) Output {
|
||||||
return &TextOutput{
|
return &text{
|
||||||
withSummary: withSummary,
|
withSummary: withSummary,
|
||||||
quiet: quiet,
|
quiet: quiet,
|
||||||
nValid: 0,
|
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()
|
o.Lock()
|
||||||
defer o.Unlock()
|
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 {
|
if o.withSummary {
|
||||||
fmt.Printf("Run summary - Valid: %d, Invalid: %d, Errors: %d Skipped: %d\n", o.nValid, o.nInvalid, o.nErrors, o.nSkipped)
|
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