From bf1fb41365fcf7fddf19629468b0dbbbe1071fbd Mon Sep 17 00:00:00 2001 From: Yanhu007 Date: Tue, 14 Apr 2026 09:41:46 +0800 Subject: [PATCH 1/2] fix: correct JSON field name typo "ValidationIssuses" -> "ValidationIssues" The Summary struct JSON tag contained a typo: "ValidationIssuses" (extra "s") instead of "ValidationIssues". This affects the JSON output format and makes it harder for consumers to parse correctly. Updated the struct tag, documentation, and all test fixtures. Note: This is a breaking change for any existing JSON parsers that use the misspelled field name. Fixes #268 --- ...tionOfMissingCRsAndUnmatchedCRsAndDiffTestsSuitesWhenNoDiffs | 2 +- .../report/testdata/DiffTestSuiteCreationWhenThereAreDiffs | 2 +- .../testdata/MissingCRstestsuitecreationwhenCRSareMissing | 2 +- docs/user-guide.md | 2 +- pkg/compare/output.go | 2 +- pkg/compare/testdata/JSONOutput/localout.golden | 2 +- pkg/compare/testdata/YAMLOutput/localout.golden | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addon-tools/report-creator/report/testdata/CreationOfMissingCRsAndUnmatchedCRsAndDiffTestsSuitesWhenNoDiffs b/addon-tools/report-creator/report/testdata/CreationOfMissingCRsAndUnmatchedCRsAndDiffTestsSuitesWhenNoDiffs index dcfe8370..c19ad368 100644 --- a/addon-tools/report-creator/report/testdata/CreationOfMissingCRsAndUnmatchedCRsAndDiffTestsSuitesWhenNoDiffs +++ b/addon-tools/report-creator/report/testdata/CreationOfMissingCRsAndUnmatchedCRsAndDiffTestsSuitesWhenNoDiffs @@ -1 +1 @@ -{"Summary":{"ValidationIssuses":{},"NumMissing":0,"UnmatchedCRS":[],"NumDiffCRs":0,"TotalCRs":27,"MetadataHash":"933892b7ae8a4f5232734acc34f6c93fc223844d836b37af390cfeaecf0b7a99","patchedCRs":0},"Diffs":[{"DiffOutput":"","CorrelatedTemplate":"cm.yaml","CRName":"v1_ConfigMap_kubernetes-dashboard_kubernetes-dashboard-settings"},{"DiffOutput":"","CorrelatedTemplate":"cr.yaml","CRName":"rbac.authorization.k8s.io/v1_ClusterRole_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"crb.yaml","CRName":"rbac.authorization.k8s.io/v1_ClusterRoleBinding_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"deploymentDashboard.yaml","CRName":"apps/v1_Deployment_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"deploymentMetrics.yaml","CRName":"apps/v1_Deployment_kubernetes-dashboard_dashboard-metrics-scraper"},{"DiffOutput":"","CorrelatedTemplate":"ns.yaml","CRName":"v1_Namespace_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"rb.yaml","CRName":"rbac.authorization.k8s.io/v1_RoleBinding_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"role.yaml","CRName":"rbac.authorization.k8s.io/v1_Role_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"sa.yaml","CRName":"v1_ServiceAccount_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"secret.yaml","CRName":"v1_Secret_kubernetes-dashboard_kubernetes-dashboard-certs"},{"DiffOutput":"","CorrelatedTemplate":"secret.yaml","CRName":"v1_Secret_kubernetes-dashboard_kubernetes-dashboard-csrf"},{"DiffOutput":"","CorrelatedTemplate":"secret.yaml","CRName":"v1_Secret_kubernetes-dashboard_kubernetes-dashboard-key-holder"},{"DiffOutput":"","CorrelatedTemplate":"service.yaml","CRName":"v1_Service_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"ns.yaml","CRName":"v1_Namespace_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"sa.yaml","CRName":"v1_ServiceAccount_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"service.yaml","CRName":"v1_Service_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"secret.yaml","CRName":"v1_Secret_kubernetes-dashboard_kubernetes-dashboard-certs"},{"DiffOutput":"","CorrelatedTemplate":"secret.yaml","CRName":"v1_Secret_kubernetes-dashboard_kubernetes-dashboard-csrf"},{"DiffOutput":"","CorrelatedTemplate":"secret.yaml","CRName":"v1_Secret_kubernetes-dashboard_kubernetes-dashboard-key-holder"},{"DiffOutput":"","CorrelatedTemplate":"cm.yaml","CRName":"v1_ConfigMap_kubernetes-dashboard_kubernetes-dashboard-settings"},{"DiffOutput":"","CorrelatedTemplate":"role.yaml","CRName":"rbac.authorization.k8s.io/v1_Role_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"cr.yaml","CRName":"rbac.authorization.k8s.io/v1_ClusterRole_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"rb.yaml","CRName":"rbac.authorization.k8s.io/v1_RoleBinding_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"crb.yaml","CRName":"rbac.authorization.k8s.io/v1_ClusterRoleBinding_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"deploymentDashboard.yaml","CRName":"apps/v1_Deployment_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"service.yaml","CRName":"v1_Service_kubernetes-dashboard_dashboard-metrics-scraper"},{"DiffOutput":"","CorrelatedTemplate":"deploymentMetrics.yaml","CRName":"apps/v1_Deployment_kubernetes-dashboard_dashboard-metrics-scraper"}]} +{"Summary":{"ValidationIssues":{},"NumMissing":0,"UnmatchedCRS":[],"NumDiffCRs":0,"TotalCRs":27,"MetadataHash":"933892b7ae8a4f5232734acc34f6c93fc223844d836b37af390cfeaecf0b7a99","patchedCRs":0},"Diffs":[{"DiffOutput":"","CorrelatedTemplate":"cm.yaml","CRName":"v1_ConfigMap_kubernetes-dashboard_kubernetes-dashboard-settings"},{"DiffOutput":"","CorrelatedTemplate":"cr.yaml","CRName":"rbac.authorization.k8s.io/v1_ClusterRole_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"crb.yaml","CRName":"rbac.authorization.k8s.io/v1_ClusterRoleBinding_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"deploymentDashboard.yaml","CRName":"apps/v1_Deployment_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"deploymentMetrics.yaml","CRName":"apps/v1_Deployment_kubernetes-dashboard_dashboard-metrics-scraper"},{"DiffOutput":"","CorrelatedTemplate":"ns.yaml","CRName":"v1_Namespace_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"rb.yaml","CRName":"rbac.authorization.k8s.io/v1_RoleBinding_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"role.yaml","CRName":"rbac.authorization.k8s.io/v1_Role_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"sa.yaml","CRName":"v1_ServiceAccount_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"secret.yaml","CRName":"v1_Secret_kubernetes-dashboard_kubernetes-dashboard-certs"},{"DiffOutput":"","CorrelatedTemplate":"secret.yaml","CRName":"v1_Secret_kubernetes-dashboard_kubernetes-dashboard-csrf"},{"DiffOutput":"","CorrelatedTemplate":"secret.yaml","CRName":"v1_Secret_kubernetes-dashboard_kubernetes-dashboard-key-holder"},{"DiffOutput":"","CorrelatedTemplate":"service.yaml","CRName":"v1_Service_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"ns.yaml","CRName":"v1_Namespace_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"sa.yaml","CRName":"v1_ServiceAccount_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"service.yaml","CRName":"v1_Service_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"secret.yaml","CRName":"v1_Secret_kubernetes-dashboard_kubernetes-dashboard-certs"},{"DiffOutput":"","CorrelatedTemplate":"secret.yaml","CRName":"v1_Secret_kubernetes-dashboard_kubernetes-dashboard-csrf"},{"DiffOutput":"","CorrelatedTemplate":"secret.yaml","CRName":"v1_Secret_kubernetes-dashboard_kubernetes-dashboard-key-holder"},{"DiffOutput":"","CorrelatedTemplate":"cm.yaml","CRName":"v1_ConfigMap_kubernetes-dashboard_kubernetes-dashboard-settings"},{"DiffOutput":"","CorrelatedTemplate":"role.yaml","CRName":"rbac.authorization.k8s.io/v1_Role_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"cr.yaml","CRName":"rbac.authorization.k8s.io/v1_ClusterRole_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"rb.yaml","CRName":"rbac.authorization.k8s.io/v1_RoleBinding_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"crb.yaml","CRName":"rbac.authorization.k8s.io/v1_ClusterRoleBinding_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"deploymentDashboard.yaml","CRName":"apps/v1_Deployment_kubernetes-dashboard_kubernetes-dashboard"},{"DiffOutput":"","CorrelatedTemplate":"service.yaml","CRName":"v1_Service_kubernetes-dashboard_dashboard-metrics-scraper"},{"DiffOutput":"","CorrelatedTemplate":"deploymentMetrics.yaml","CRName":"apps/v1_Deployment_kubernetes-dashboard_dashboard-metrics-scraper"}]} diff --git a/addon-tools/report-creator/report/testdata/DiffTestSuiteCreationWhenThereAreDiffs b/addon-tools/report-creator/report/testdata/DiffTestSuiteCreationWhenThereAreDiffs index 29ec6cc8..8f45b936 100644 --- a/addon-tools/report-creator/report/testdata/DiffTestSuiteCreationWhenThereAreDiffs +++ b/addon-tools/report-creator/report/testdata/DiffTestSuiteCreationWhenThereAreDiffs @@ -1 +1 @@ -{"Summary":{"ValidationIssuses":{},"NumMissing":0,"UnmatchedCRS":[],"NumDiffCRs":1,"TotalCRs":1,"MetadataHash":"013675dbf39d109d2e17bef23e4786717e5439e5490cf20853af5481f0818c40","patchedCRs":0},"Diffs":[{"DiffOutput":"diff -u -N TEMP/v1_configmap_kubernetes-dashboard_kubernetes-dashboard-settings TEMP/v1_configmap_kubernetes-dashboard_kubernetes-dashboard-settings\n--- TEMP/v1_configmap_kubernetes-dashboard_kubernetes-dashboard-settings\tDATE\n+++ TEMP/v1_configmap_kubernetes-dashboard_kubernetes-dashboard-settings\tDATE\n@@ -2,6 +2,6 @@\n kind: ConfigMap\n metadata:\n labels:\n- k8s-app: kubernetes-dashboardfunction was called successfully from different file\n+ k8s-app: kubernetes-dashboard\n name: kubernetes-dashboard-settings\n namespace: kubernetes-dashboard\n","CorrelatedTemplate":"cm.yaml","CRName":"v1_ConfigMap_kubernetes-dashboard_kubernetes-dashboard-settings"}]} +{"Summary":{"ValidationIssues":{},"NumMissing":0,"UnmatchedCRS":[],"NumDiffCRs":1,"TotalCRs":1,"MetadataHash":"013675dbf39d109d2e17bef23e4786717e5439e5490cf20853af5481f0818c40","patchedCRs":0},"Diffs":[{"DiffOutput":"diff -u -N TEMP/v1_configmap_kubernetes-dashboard_kubernetes-dashboard-settings TEMP/v1_configmap_kubernetes-dashboard_kubernetes-dashboard-settings\n--- TEMP/v1_configmap_kubernetes-dashboard_kubernetes-dashboard-settings\tDATE\n+++ TEMP/v1_configmap_kubernetes-dashboard_kubernetes-dashboard-settings\tDATE\n@@ -2,6 +2,6 @@\n kind: ConfigMap\n metadata:\n labels:\n- k8s-app: kubernetes-dashboardfunction was called successfully from different file\n+ k8s-app: kubernetes-dashboard\n name: kubernetes-dashboard-settings\n namespace: kubernetes-dashboard\n","CorrelatedTemplate":"cm.yaml","CRName":"v1_ConfigMap_kubernetes-dashboard_kubernetes-dashboard-settings"}]} diff --git a/addon-tools/report-creator/report/testdata/MissingCRstestsuitecreationwhenCRSareMissing b/addon-tools/report-creator/report/testdata/MissingCRstestsuitecreationwhenCRSareMissing index 0af71099..69856c0d 100644 --- a/addon-tools/report-creator/report/testdata/MissingCRstestsuitecreationwhenCRSareMissing +++ b/addon-tools/report-creator/report/testdata/MissingCRstestsuitecreationwhenCRSareMissing @@ -1 +1 @@ -{"Summary":{"ValidationIssuses":{"ExamplePart1":{"Dashboard1":{"Msg":"Missing CRs","CRs":["cm.yaml"]},"Dashboard2":{"Msg":"Missing CRs","CRs":["deploymentDashboard.yaml","deploymentMetrics.yaml"]}},"ExamplePart2":{"Dashboard1":{"Msg":"Missing CRs","CRs":["cr.yaml"]},"Dashboard2":{"Msg":"Missing CRs","CRs":["crb.yaml"]}}},"NumMissing":5,"UnmatchedCRS":[],"NumDiffCRs":0,"TotalCRs":1,"MetadataHash":"98dca024e0509f46f0a228da2ad61b98804a3f4b5a7ad1ac31d41b46812c32ea","patchedCRs":0},"Diffs":[{"DiffOutput":"","CorrelatedTemplate":"ns.yaml","CRName":"v1_Namespace_kubernetes-dashboard"}]} +{"Summary":{"ValidationIssues":{"ExamplePart1":{"Dashboard1":{"Msg":"Missing CRs","CRs":["cm.yaml"]},"Dashboard2":{"Msg":"Missing CRs","CRs":["deploymentDashboard.yaml","deploymentMetrics.yaml"]}},"ExamplePart2":{"Dashboard1":{"Msg":"Missing CRs","CRs":["cr.yaml"]},"Dashboard2":{"Msg":"Missing CRs","CRs":["crb.yaml"]}}},"NumMissing":5,"UnmatchedCRS":[],"NumDiffCRs":0,"TotalCRs":1,"MetadataHash":"98dca024e0509f46f0a228da2ad61b98804a3f4b5a7ad1ac31d41b46812c32ea","patchedCRs":0},"Diffs":[{"DiffOutput":"","CorrelatedTemplate":"ns.yaml","CRName":"v1_Namespace_kubernetes-dashboard"}]} diff --git a/docs/user-guide.md b/docs/user-guide.md index 1ba4527e..6f5c0170 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -175,7 +175,7 @@ For example: ```json { "Summary": { - "ValidationIssuses": { + "ValidationIssues": { "ExamplePart": { "Dashboard": { "Msg": "Missing CRs", diff --git a/pkg/compare/output.go b/pkg/compare/output.go index 9d816b24..0287991a 100644 --- a/pkg/compare/output.go +++ b/pkg/compare/output.go @@ -74,7 +74,7 @@ func (s DiffSum) WasPatched() bool { // Summary Contains all info included in the Summary output of the compare command type Summary struct { - ValidationIssues map[string]map[string]ValidationIssue `json:"ValidationIssuses"` + ValidationIssues map[string]map[string]ValidationIssue `json:"ValidationIssues"` NumMissing int `json:"NumMissing"` UnmatchedCRS []string `json:"UnmatchedCRS"` NumDiffCRs int `json:"NumDiffCRs"` diff --git a/pkg/compare/testdata/JSONOutput/localout.golden b/pkg/compare/testdata/JSONOutput/localout.golden index 2eb9413c..f9b355f6 100644 --- a/pkg/compare/testdata/JSONOutput/localout.golden +++ b/pkg/compare/testdata/JSONOutput/localout.golden @@ -1 +1 @@ -{"Summary":{"ValidationIssuses":{"ExamplePart":{"Dashboard":{"Msg":"Missing CRs","CRs":["deploymentDashboard.yaml"]}}},"NumMissing":1,"UnmatchedCRS":[],"NumDiffCRs":1,"TotalCRs":1,"MetadataHash":"aa4c94f1307788e1da81f57718a9f1364d35d4ff6099fc633724bcf9d051a094","patchedCRs":0},"Diffs":[{"DiffOutput":"diff -u -N TEMP/apps-v1_deployment_kubernetes-dashboard_dashboard-metrics-scraper TEMP/apps-v1_deployment_kubernetes-dashboard_dashboard-metrics-scraper\n--- TEMP/apps-v1_deployment_kubernetes-dashboard_dashboard-metrics-scraper\tDATE\n+++ TEMP/apps-v1_deployment_kubernetes-dashboard_dashboard-metrics-scraper\tDATE\n@@ -10,7 +10,7 @@\n revisionHistoryLimit: 10\n selector:\n matchLabels:\n- k8s-app: dashboard-metrics-scraper\n+ k8s-app: dashboard-metrics-scraper-diff\n template:\n metadata:\n labels:\n","CorrelatedTemplate":"deploymentMetrics.yaml","CRName":"apps/v1_Deployment_kubernetes-dashboard_dashboard-metrics-scraper"}]} +{"Summary":{"ValidationIssues":{"ExamplePart":{"Dashboard":{"Msg":"Missing CRs","CRs":["deploymentDashboard.yaml"]}}},"NumMissing":1,"UnmatchedCRS":[],"NumDiffCRs":1,"TotalCRs":1,"MetadataHash":"aa4c94f1307788e1da81f57718a9f1364d35d4ff6099fc633724bcf9d051a094","patchedCRs":0},"Diffs":[{"DiffOutput":"diff -u -N TEMP/apps-v1_deployment_kubernetes-dashboard_dashboard-metrics-scraper TEMP/apps-v1_deployment_kubernetes-dashboard_dashboard-metrics-scraper\n--- TEMP/apps-v1_deployment_kubernetes-dashboard_dashboard-metrics-scraper\tDATE\n+++ TEMP/apps-v1_deployment_kubernetes-dashboard_dashboard-metrics-scraper\tDATE\n@@ -10,7 +10,7 @@\n revisionHistoryLimit: 10\n selector:\n matchLabels:\n- k8s-app: dashboard-metrics-scraper\n+ k8s-app: dashboard-metrics-scraper-diff\n template:\n metadata:\n labels:\n","CorrelatedTemplate":"deploymentMetrics.yaml","CRName":"apps/v1_Deployment_kubernetes-dashboard_dashboard-metrics-scraper"}]} diff --git a/pkg/compare/testdata/YAMLOutput/localout.golden b/pkg/compare/testdata/YAMLOutput/localout.golden index 8fa14de0..328a8b23 100644 --- a/pkg/compare/testdata/YAMLOutput/localout.golden +++ b/pkg/compare/testdata/YAMLOutput/localout.golden @@ -12,7 +12,7 @@ Summary: NumMissing: 1 TotalCRs: 1 UnmatchedCRS: [] - ValidationIssuses: + ValidationIssues: ExamplePart: Dashboard: CRs: From f7a706a66f7168613100102925839a1f83bb882a Mon Sep 17 00:00:00 2001 From: Yanhu007 Date: Tue, 14 Apr 2026 11:34:16 +0800 Subject: [PATCH 2/2] docs: add migration note for renamed ValidationIssues JSON field Address CodeRabbit review suggestion: add a note near the JSON example explaining the renamed key for downstream parsers. --- docs/user-guide.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/user-guide.md b/docs/user-guide.md index 6f5c0170..b6d91739 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -172,6 +172,8 @@ easily parsed by other software. For example: +> **Note:** The JSON field `Summary.ValidationIssuses` was renamed to `Summary.ValidationIssues` (typo fix). Consumers parsing the old key name must update. + ```json { "Summary": {