Skip to content

Commit

Permalink
Merge pull request #295 from flanksource/remove-managed-fields
Browse files Browse the repository at this point in the history
fix: remove `manageFields` from Kubernetes event
  • Loading branch information
moshloop authored Sep 5, 2023
2 parents 29d15a5 + f7daac4 commit 2827540
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
39 changes: 30 additions & 9 deletions fixtures/expected/file-git.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,55 @@
"name": "http-pass-single"
},
"spec": {
"interval": 30,
"http": [
{
"endpoint": "https://httpbin.demo.aws.flanksource.com/status/200",
"name": "http-deprecated-endpoint"
},
{
"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
]
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion scrapers/kubernetes/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2827540

Please sign in to comment.