Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(GetUnusedAll) - JSON concatenation #227

Merged
merged 1 commit into from Mar 20, 2024

Conversation

doronkg
Copy link
Contributor

@doronkg doronkg commented Mar 19, 2024

This PR aims to resolve #226.
Currently when executing GetUnusedAll() with JSON format, instead of merging the two lists, it appends them.
This also resolves the Error parsing JSON: invalid character '{' after top-level value returned from kor exporter.

Before the fix:

$ kor all -o json
{
  "test": {
    "ConfigMap": null,
    "DaemonSet": null,
    "Deployment": null,
    "Hpa": [
      "php-apache"
    ],
    "Ingress": [
      "test-ingress-1-work"
    ],
    "Job": null,
    "Pdb": null,
    "Pvc": [
      "myclaim"
    ],
    "ReplicaSet": null,
    "Role": null,
    "Secret": null,
    "Service": [
      "app1-service",
      "app2-service"
    ],
    "ServiceAccount": null,
    "StatefulSet": null
  }
}{
  "": {
    "ClusterRole": [
      "admin",
      "view"
    ],
    "Crd": [
      "thanosrulers.monitoring.coreos.com"
    ],
    "Pv": null,
    "StorageClass": null
  }
}

After the fix:

$ kor all -o json
{
  "": {
    "ClusterRole": [
      "admin",
      "view"
    ],
    "Crd": [
      "thanosrulers.monitoring.coreos.com"
    ],
    "Pv": null,
    "StorageClass": null
  },
  "test": {
    "ConfigMap": null,
    "DaemonSet": null,
    "Deployment": null,
    "Hpa": [
      "php-apache"
    ],
    "Ingress": [
      "test-ingress-1-work"
    ],
    "Job": null,
    "Pdb": null,
    "Pvc": [
      "myclaim"
    ],
    "ReplicaSet": null,
    "Role": null,
    "Secret": null,
    "Service": [
      "app1-service",
      "app2-service"
    ],
    "ServiceAccount": null,
    "StatefulSet": null
  }
}

@codecov-commenter
Copy link

Codecov Report

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

Project coverage is 47.20%. Comparing base (4a79f02) to head (6cda98e).

Files Patch % Lines
pkg/kor/all.go 0.00% 25 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #227      +/-   ##
==========================================
- Coverage   47.58%   47.20%   -0.38%     
==========================================
  Files          32       32              
  Lines        2915     2938      +23     
==========================================
  Hits         1387     1387              
- Misses       1354     1377      +23     
  Partials      174      174              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pkg/kor/all.go Show resolved Hide resolved
Copy link
Owner

@yonahd yonahd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@yonahd yonahd merged commit cdff99c into yonahd:main Mar 20, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: kor exporter cannot parse json
3 participants