From 36208595403f4ca0cf10b93fe6dee6eade4e139d Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Tue, 5 Sep 2023 15:58:12 +0545 Subject: [PATCH 1/2] fix: remove manageFields from Kubernetes event --- scrapers/kubernetes/events.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scrapers/kubernetes/events.go b/scrapers/kubernetes/events.go index 7fe9374e..36430474 100644 --- a/scrapers/kubernetes/events.go +++ b/scrapers/kubernetes/events.go @@ -72,8 +72,14 @@ func getDetailsFromEvent(obj *unstructured.Unstructured) map[string]any { details := make(map[string]any) for k, v := range obj.Object { - if k == "involvedObject" { + switch k { + case "involvedObject": continue + + case "metadata": + if metadata, ok := v.(map[string]any); ok { + delete(metadata, "managedFields") + } } details[k] = v From f7daac4a56f4a43620ebefd668f5b1ae5756a818 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Tue, 5 Sep 2023 16:23:02 +0545 Subject: [PATCH 2/2] fix: test. updated expectation --- fixtures/expected/file-git.json | 39 +++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/fixtures/expected/file-git.json b/fixtures/expected/file-git.json index ef24ac9a..dc5b11c3 100644 --- a/fixtures/expected/file-git.json +++ b/fixtures/expected/file-git.json @@ -14,6 +14,7 @@ "name": "http-pass-single" }, "spec": { + "interval": 30, "http": [ { "endpoint": "https://httpbin.demo.aws.flanksource.com/status/200", @@ -21,27 +22,47 @@ }, { "name": "http-minimal-check", - "url": "https://httpbin.demo.aws.flanksource.com/status/200" + "url": "https://httpbin.demo.aws.flanksource.com/status/200", + "metrics": [ + { + "name": "httpbin_2xx_count", + "type": "counter", + "value": "result.code == 200 ? 1 : 0", + "labels": [ + { + "name": "name", + "value": "httpbin_2xx_count" + }, + { + "name": "check_name", + "valueExpr": "check.name" + }, + { + "name": "status_class", + "valueExpr": "string(result.code).charAt(0)" + } + ] + } + ] }, { - "maxSSLExpiry": 7, "name": "http-param-tests", + "url": "https://httpbin.demo.aws.flanksource.com/status/200", "responseCodes": [201, 200, 301], "responseContent": "", - "url": "https://httpbin.demo.aws.flanksource.com/status/200" + "maxSSLExpiry": 7 }, { - "display": { - "template": "code={{.code}}, age={{.sslAge}}" - }, "name": "http-expr-tests", + "url": "https://httpbin.demo.aws.flanksource.com/status/200", "test": { "expr": "code in [200,201,301] && sslAge > Duration('7d')" }, - "url": "https://httpbin.demo.aws.flanksource.com/status/200" + "display": { + "template": "code={{.code}}, age={{.sslAge}}" + } } - ], - "interval": 30 + ] } } }