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

JSON Output Overwrites Results for Different Namespaces #51

Open
andrewtengson opened this issue Nov 15, 2023 · 1 comment
Open

JSON Output Overwrites Results for Different Namespaces #51

andrewtengson opened this issue Nov 15, 2023 · 1 comment

Comments

@andrewtengson
Copy link

andrewtengson commented Nov 15, 2023

Problem:

The JSON output for namespace-based results overwrites previous entries, leading to loss of data for different namespaces. This occurs because the namespace is not included in the JSON path.

Expected Behavior:

Each namespace-based result should be independently added to the JSON output without overwriting others.

Actual Behavior:

Only the last namespace-based result is retained in the JSON output.

Steps to Reproduce:

  1. Generate a report with multiple namespace-based results.
  2. Observe the JSON output.

Affected Version:

<=v0.10.4

Text Output:

│ applications │ argo           │ Deploy horizontal pod autoscaler for deployments. │ argo-cd-argocd-applicationset-controller │ Deployment    │ Link       │ 
│ applications │ dynatrace      │ Deploy horizontal pod autoscaler for deployments. │ dynatrace-operator                       │ Deployment    │ Link       │ 
│ applications │ port           │ Deploy horizontal pod autoscaler for deployments. │                                          │ Deployment    │ Link       │ 

JSON Output:

{
  "namespace_based": {
    "reliability": {
      "applications": {
        {
          "Deploy horizontal pod autoscaler for deployments.": {
            "status": true,
            "resources": [
              ""
            ],
            "resource_type": "Deployment",
            "namespace": "port",
            "resolution": "https://aws.github.io/aws-eks-best-practices/reliability/docs/application/#horizontal-pod-autoscaler-hpa"
          }
        }
      }
    }
  }
}

Proposed Solution:

Include the namespace in the JSON path to ensure unique addressing for each result. The modified code snippet is as follows:

json_blob[rule._type][rule.pillar][rule.section][rule.message] = result

-        json_blob[rule._type][rule.pillar][rule.section][rule.message] = result
+        if rule._type == "namespace_based":
+            json_blob[rule._type][rule.pillar][rule.section][rule.result.namespace][rule.message] = result
+        else:
+            json_blob[rule._type][rule.pillar][rule.section][rule.message] = result

bc6a1d5
This change ensures that results for different namespaces are stored under their respective namespace keys, preventing data overwrites.

@dorukozturk
Copy link
Contributor

Apologies for the late response. Thank you very much for creating an issue. I will take a look right after reinvent !

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

No branches or pull requests

2 participants