kubeval
kubeval copied to clipboard
OutputManager handles error output
This pull request corrects output inconsistencies when errors are found before the configuration hits the schema validator. See: #332
If one specifies the output type of json -o json
and the config is missing 'apiversion' or 'kind' fields, the error output takes the form of a standard string.
Error handling currently bypasses the OutputManager and dumps errors to stdout as regular strings. This update redirects error output to OutputManager. Kubeval still fails fast when a config is loaded that is missing the necessary fields.
Example of config output with and without changes:
# test.yaml
# apiVersion: apps/v1
kind: Deployment
metadata:
name: moda-sandbox
Current output:
$ go run main.go -d test.yaml -o json
ERR - test.yaml: Missing 'apiVersion' key
null
With updates:
[
{
"filename": "test.yaml",
"kind": "",
"status": "invalid",
"errors": [
"apiVersion: apiVersion key is required"
]
}
]