stackrox / kube-linter

KubeLinter is a static analysis tool that checks Kubernetes YAML files and Helm charts to ensure the applications represented in them adhere to best practices.
https://docs.kubelinter.io/
Apache License 2.0
2.98k stars 234 forks source link

Improved errors for invalid yaml files #63

Open IAmATeaPot418 opened 4 years ago

IAmATeaPot418 commented 4 years ago

Today, kube-linter shows the output Warning: no valid objects found. when there is an invalid yaml file.

The error messages could be made more clear. Rather than asking users to use verbose logging kube-linter lint -v pod.yaml we should display errors that showcase what the issue is. I think it would be ideal to have custom error conditions to show users why something is not valid.

Option 1: The file scanned at ./pod.yaml is not a valid yaml file. Please check to ensure the file is in proper yaml format. Option 2: The file scanned is not a valid kubernetes object please run kube-linter lint -v pod.yaml for more details.

Alternatively, we could also point them to run kube-linter lint -v pod.yaml for more details directly in the error.

janisz commented 2 years ago

This is partially solve by #279 As @IAmATeaPot418 mentioned for better UX we should inform user about --fail-on-invalid-resource and -v options and enable fail-on-invalid-resource as default from next major release.

ThZev commented 1 year ago

Is there support for --fail-on-invalid-resource in the Github action? Is there a way to enable the setting via config file kube-linter.yaml ?

janisz commented 1 year ago

Indeed it's not exposed in config nor available in the action.

gecube commented 2 months ago

As a DevOps Engineer I want to have one tool to make all checks regarding k8s yaml files. Let's say:

$ kustomize build .
Error: accumulating resources: accumulating resources from '30-comtelml.registry.yaml': MalformedYAMLError: yaml: line 17: mapping values are not allowed in this context in File: 30-comtelml.registry.yaml
gaal@bigsur apps % kustomize build .

so it means that I need to use more tools than it could be possible.

BTW, the key mentioned before --fail-on-invalid-resource - is not detecting the issue as well.