Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OutputManager handles error output #333

Closed
wants to merge 1 commit into from

Conversation

mbaum0
Copy link

@mbaum0 mbaum0 commented Mar 1, 2022

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"
                ]
        }
]

@mbaum0 mbaum0 closed this Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant