datreeio / datree

Prevent Kubernetes misconfigurations from reaching production (again 😤 )! From code to cloud, Datree provides an E2E policy enforcement solution to run automatic checks for rule violations. See our docs: https://hub.datree.io
https://datree.io
Apache License 2.0
6.39k stars 363 forks source link

`--only-k8s-files` flag is not working #425

Closed eyarz closed 2 years ago

eyarz commented 2 years ago

Describe the bug The --only-k8s-files flag should skip files that are NOT k8s to avoid false-positive results when scanning a dir with k8s and non-k8s files

To Reproduce Steps to reproduce the behavior:

  1. Run command datree test README.md --only-k8s-files
  2. See the YAML validation error

Expected behavior because README.md is not a k8s file, the CLI should skip it.

Screenshots image

Desktop (please complete the following information):

Datree version (run datree version):

eyarz commented 2 years ago

The --only-k8s-file flag supports only YAML files because this check (k8s file or not) is happening after the YAML validation step. Because I used this flag on a README file, it was not ignored.

We don't want to skip the YAML validation step so we will not fix this bug. If someone wants to scan an entire dir with a mix of k8s and none k8s files, he should use the following workaround: datree test path/to/dir/*.ya?ml --only-k8s-files