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

Running test on non k8s yaml files with `--only-k8s-files` flag raises an error #430

Closed TzlilSwimmer123 closed 2 years ago

TzlilSwimmer123 commented 2 years ago

Describe the bug Running datree test on non k8s files with --only-k8s-files flag raises invalid memory address or nil pointer dereference error on runtime

To Reproduce Steps to reproduce the behavior:

  1. Run command 'datree test internal/fixtures/kube/Chart.yaml --only-k8s-files'
  2. See error

Expected behavior Suppose to show test results - this file/these files should be presented with their invalidation error

Screenshots

Screen Shot 2022-02-23 at 12 29 38

Desktop (please complete the following information):

Datree version:

royhadad commented 2 years ago

After some investigation, I found that this happens because of this line: https://github.com/datreeio/datree/blob/34815cb824e4ef8b205c322bbf7d727228898876/cmd/test/main.go#L405 Screen Shot 2022-03-09 at 17 18 42

results.EvaluationResults is equal to null, which causes a runtime error