diff --git a/pkg/output/json.go b/pkg/output/json.go index 09d96b4..bc9d7e4 100644 --- a/pkg/output/json.go +++ b/pkg/output/json.go @@ -57,7 +57,7 @@ func (o *jsono) Write(filename, kind, version string, err error, skipped bool) { o.nSkipped++ } - if o.verbose || s == VALID || s == SKIPPED { + if o.verbose || (s != VALID && s != SKIPPED) { o.results = append(o.results, result{Filename: filename, Kind: kind, Version: version, Status: st, Msg: msg}) } } diff --git a/pkg/output/json_test.go b/pkg/output/json_test.go index 3b6129c..d1ba792 100644 --- a/pkg/output/json_test.go +++ b/pkg/output/json_test.go @@ -6,7 +6,6 @@ import ( ) func TestJSONWrite(t *testing.T) { - type result struct { fileName, kind, version string err error @@ -22,7 +21,7 @@ func TestJSONWrite(t *testing.T) { expect string } { { - "a single deployment, no summary", + "a single deployment, no summary, no verbose", false, false, []result{ @@ -35,20 +34,12 @@ func TestJSONWrite(t *testing.T) { }, }, `{ - "resources": [ - { - "filename": "deployment.yml", - "kind": "Deployment", - "version": "apps/v1", - "status": "VALID", - "msg": "" - } - ] + "resources": [] } `, }, { - "a single deployment, with summary", + "a single deployment, summary, no verbose", true, false, []result{ @@ -61,6 +52,30 @@ func TestJSONWrite(t *testing.T) { }, }, `{ + "resources": [], + "summary": { + "valid": 1, + "invalid": 0, + "errors": 0, + "skipped": 0 + } +} +`, + }, + { + "a single deployment, verbose, with summary", + true, + true, + []result{ + { + "deployment.yml", + "Deployment", + "apps/v1", + nil, + false, + }, + }, + `{ "resources": [ { "filename": "deployment.yml",