yonahd / kor

A Golang Tool to discover unused Kubernetes Resources
MIT License
1.04k stars 96 forks source link

fix(multi): Support grouping by resource in multi resource mode #320

Closed doronkg closed 4 months ago

doronkg commented 4 months ago

What this PR does / why we need it?

This PR adds support to use --group-by=resource flag in multi resource mode. In addition, it improves the output by adding newlines in similar to --group-by=namespace output.

$ .\main.exe sa,clusterrole --group-by=resource -o json
{
  "ClusterRole": {
    "": [
      "aaa"
    ]
  },
  "ServiceAccount": {
    "kube-system": [
      "tes2t"
  }
}

PR Checklist

GitHub Issue

Closes #289

codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 0% with 30 lines in your changes missing coverage. Please review.

Project coverage is 41.74%. Comparing base (bc2cca8) to head (7ef8742).

Files Patch % Lines
pkg/kor/multi.go 0.00% 29 Missing :warning:
pkg/kor/formatter.go 0.00% 1 Missing :warning:

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

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #320 +/- ## ========================================== - Coverage 41.77% 41.74% -0.03% ========================================== Files 61 61 Lines 3179 3181 +2 ========================================== Hits 1328 1328 - Misses 1637 1639 +2 Partials 214 214 ```

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