instrumenta / kubeval

Validate your Kubernetes configuration files, supports multiple Kubernetes versions
https://kubeval.com
Other
3.16k stars 229 forks source link

Should not PASS on empty input #218

Open ambis opened 4 years ago

ambis commented 4 years ago

Considering that kubeval is probably run mostly in CI pipelines, I think it is funny that kubeval exits with 0 when it gets an empty input.

Do you guys consider that it is more likely that you would intentionally pass empty input to kubeval, OR could that possibly be a sign of a previous error that there is no input to validate?

I know you can't change this outright for BC, but a flag for "--fail-if-empty" would be a welcome addition for CI environments.

hobti01 commented 4 years ago

IMO this should be opt-in. Helm can create empty files if the template does not write any content, such as the case of a conditional file, and this should not cause kubeval to fail.

yannh commented 3 years ago

I would be interested with what you define as "empty input" - a folder with at least a single file that is empty? Should a file with an empty resource, eg

`

Kind: Deployment [A valid resource here]


` Notice the two yaml separators ^ - seems like this is breaking the Markdown rendering sorry.

Or do you mean - when kubeval reads from stdin, and stdin is empty? could you clarify? Thanks!

Kampe commented 3 years ago

I agree, if passed empty yaml there should be an option to fail. This would be incredibly useful as Kustomize, on error, produces empty manifests.