yonahd / kor

A Golang Tool to discover unused Kubernetes Resources
MIT License
1.05k stars 97 forks source link

Excluding labels doesn't work #384

Closed nemcikjan closed 5 hours ago

nemcikjan commented 1 day ago

Describe the bug If using cli with -l/--exclude-labels flag, the filtering is not working

To Reproduce Steps to reproduce the behavior: Resource labels:

kubectl get pvc -n default pvc-claim-2 -o jsonpath={.metadata.labels}

{"kor/report":"false","reporting":"no"}

Command:

kor -l reporting=no persistentvolumeclaim

Output:

kor version: vdev

  _  _____  ____
 | |/ / _ \|  _ \
 | ' / | | | |_) |
 | . \ |_| |  _ <
 |_|\_\___/|_| \_\

Unused resources in namespace: "default"
+---+---------------+---------------+
| # | RESOURCE TYPE | RESOURCE NAME |
+---+---------------+---------------+
| 1 | Pvc           | pvc-claim-2   |
+---+---------------+---------------+

Expected behavior The resources shouldn't be matched but the output is the following:

kor --exclude-labels reporting=no persistentvolumeclaim
kor version: vdev

  _  _____  ____
 | |/ / _ \|  _ \
 | ' / | | | |_) |
 | . \ |_| |  _ <
 |_|\_\___/|_| \_\

Unused resources in namespace: "default"
+---+---------------+---------------+
| # | RESOURCE TYPE | RESOURCE NAME |
+---+---------------+---------------+
| 1 | Pvc           | pvc-claim-2   |
+---+---------------+---------------+

OS version, architecture and kor version Darwin_arm64 Kor version: vdev (brew installation of stable version 0.5.6)

yonahd commented 1 day ago

Marking this as a bug @nemcikjan in the meantime can you try this https://github.com/yonahd/kor?tab=readme-ov-file#ignore-resources This should help exclude the resource

nemcikjan commented 11 hours ago

Marking this as a bug @nemcikjan in the meantime can you try this https://github.com/yonahd/kor?tab=readme-ov-file#ignore-resources This should help exclude the resource

@yonahd the default label for excluding is working

doronkg commented 9 hours ago

/assign Not all resources were refactored with the new filtering interface, I'll create a PR for that.