mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-20 10:27:02 +00:00
Add test to JSON output with validationError
This commit is contained in:
parent
2b4dc8f9f2
commit
d329fa6483
2 changed files with 60 additions and 2 deletions
|
|
@ -50,11 +50,15 @@ func (o *jsono) Write(result validator.Result) error {
|
||||||
o.nValid++
|
o.nValid++
|
||||||
case validator.Invalid:
|
case validator.Invalid:
|
||||||
st = "statusInvalid"
|
st = "statusInvalid"
|
||||||
msg = result.Err.Error()
|
if result.Err != nil {
|
||||||
|
msg = result.Err.Error()
|
||||||
|
}
|
||||||
o.nInvalid++
|
o.nInvalid++
|
||||||
case validator.Error:
|
case validator.Error:
|
||||||
st = "statusError"
|
st = "statusError"
|
||||||
msg = result.Err.Error()
|
if result.Err != nil {
|
||||||
|
msg = result.Err.Error()
|
||||||
|
}
|
||||||
o.nErrors++
|
o.nErrors++
|
||||||
case validator.Skipped:
|
case validator.Skipped:
|
||||||
st = "statusSkipped"
|
st = "statusSkipped"
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,60 @@ metadata:
|
||||||
"skipped": 0
|
"skipped": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"a single invalid deployment, verbose, with summary",
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
[]validator.Result{
|
||||||
|
{
|
||||||
|
Resource: resource.Resource{
|
||||||
|
Path: "deployment.yml",
|
||||||
|
Bytes: []byte(`apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: "my-app"
|
||||||
|
`),
|
||||||
|
},
|
||||||
|
Status: validator.Invalid,
|
||||||
|
Err: &validator.ValidationError{
|
||||||
|
Path: "foo",
|
||||||
|
Msg: "bar",
|
||||||
|
},
|
||||||
|
ValidationErrors: []validator.ValidationError{
|
||||||
|
{
|
||||||
|
Path: "foo",
|
||||||
|
Msg: "bar",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
`{
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"filename": "deployment.yml",
|
||||||
|
"kind": "Deployment",
|
||||||
|
"name": "my-app",
|
||||||
|
"version": "apps/v1",
|
||||||
|
"status": "statusInvalid",
|
||||||
|
"msg": "bar",
|
||||||
|
"validationErrors": [
|
||||||
|
{
|
||||||
|
"path": "foo",
|
||||||
|
"msg": "bar"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"summary": {
|
||||||
|
"valid": 0,
|
||||||
|
"invalid": 1,
|
||||||
|
"errors": 0,
|
||||||
|
"skipped": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue