yonahd / kor

A Golang Tool to discover unused Kubernetes Resources
MIT License
974 stars 91 forks source link

feat: Add OpenShift exceptions #311

Closed doronkg closed 3 months ago

doronkg commented 3 months ago

What this PR does / why we need it

This PR excludes the default resources created in basic OpenShift installations. In addition, I've moved the config load out of the processing loop in most resource types, to reduce excessive iterations.

PR Checklist

GitHub Issue

Closes #240

Notes for your reviewers

In pkg/kor/secrets.go, a new exception secret type was added - kubernetes.io/dockercfg, which is the OpenShift equivalent of kubernetes.io/dockerconfigjson.

Basic OpenShift installation comes with 60+ namespaces beginning with openshift- prefix, which doesn't include additional namespaces created by OpenShift operators or customized installations, that would also be created with that prefix. For that case, I've excluded all openshift- namespaces in all relevant namespaced resource types, with the following pattern:

    {
      "Namespace": "openshift-.*",
      "ResourceName": ".*",
      "MatchRegex": true
    }
codecov-commenter commented 3 months ago

Codecov Report

Attention: Patch coverage is 27.02703% with 27 lines in your changes missing coverage. Please review.

Project coverage is 41.30%. Comparing base (a2f3629) to head (92d3283).

Files Patch % Lines
pkg/kor/pdbs.go 25.00% 3 Missing and 3 partials :warning:
pkg/kor/replicaset.go 25.00% 3 Missing and 3 partials :warning:
pkg/kor/crds.go 0.00% 3 Missing :warning:
pkg/kor/clusterroles.go 33.33% 1 Missing and 1 partial :warning:
pkg/kor/daemonsets.go 33.33% 1 Missing and 1 partial :warning:
pkg/kor/roles.go 33.33% 1 Missing and 1 partial :warning:
pkg/kor/secrets.go 33.33% 1 Missing and 1 partial :warning:
pkg/kor/services.go 33.33% 1 Missing and 1 partial :warning:
pkg/kor/storageclasses.go 33.33% 1 Missing and 1 partial :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #311 +/- ## ========================================== - Coverage 41.38% 41.30% -0.09% ========================================== Files 61 61 Lines 3204 3220 +16 ========================================== + Hits 1326 1330 +4 - Misses 1668 1674 +6 - Partials 210 216 +6 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.