mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-18 09:27:02 +00:00
fix json output
This commit is contained in:
parent
f718b2c919
commit
c3a25b9689
2 changed files with 28 additions and 13 deletions
|
|
@ -57,7 +57,7 @@ func (o *jsono) Write(filename, kind, version string, err error, skipped bool) {
|
||||||
o.nSkipped++
|
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})
|
o.results = append(o.results, result{Filename: filename, Kind: kind, Version: version, Status: st, Msg: msg})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestJSONWrite(t *testing.T) {
|
func TestJSONWrite(t *testing.T) {
|
||||||
|
|
||||||
type result struct {
|
type result struct {
|
||||||
fileName, kind, version string
|
fileName, kind, version string
|
||||||
err error
|
err error
|
||||||
|
|
@ -22,7 +21,7 @@ func TestJSONWrite(t *testing.T) {
|
||||||
expect string
|
expect string
|
||||||
} {
|
} {
|
||||||
{
|
{
|
||||||
"a single deployment, no summary",
|
"a single deployment, no summary, no verbose",
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
[]result{
|
[]result{
|
||||||
|
|
@ -35,20 +34,12 @@ func TestJSONWrite(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
`{
|
`{
|
||||||
"resources": [
|
"resources": []
|
||||||
{
|
|
||||||
"filename": "deployment.yml",
|
|
||||||
"kind": "Deployment",
|
|
||||||
"version": "apps/v1",
|
|
||||||
"status": "VALID",
|
|
||||||
"msg": ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"a single deployment, with summary",
|
"a single deployment, summary, no verbose",
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
[]result{
|
[]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": [
|
"resources": [
|
||||||
{
|
{
|
||||||
"filename": "deployment.yml",
|
"filename": "deployment.yml",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue