From f517726185cbda3c54d2a204b3addaf04c6d2b68 Mon Sep 17 00:00:00 2001 From: Matthew McKeen Date: Tue, 27 Jun 2023 10:41:17 -0700 Subject: [PATCH 1/4] Allow filtering out normal events --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.go b/main.go index 4ebdc68..a090713 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "flag" "fmt" "log" "os" @@ -15,7 +16,13 @@ import ( "k8s.io/client-go/tools/clientcmd" ) +var ( + ignoreNormal = flag.Bool("ignore_normal", false, "ignore events of the normal type, they can be noisy") +) + func main() { + flag.Parse() + loggerApplication := log.New(os.Stderr, "", log.LstdFlags) loggerEvent := log.New(os.Stdout, "", 0) @@ -65,6 +72,9 @@ func main() { 0, cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { + if (*ignoreNormal && obj.(corev1.Event).Type == corev1.EventTypeNormal) { + return + } j, _ := json.Marshal(obj) loggerEvent.Printf("%s\n", string(j)) }, From 06fdac82157fdd9fa4fb4c3cb3aa849dfb965445 Mon Sep 17 00:00:00 2001 From: Matthew McKeen Date: Tue, 27 Jun 2023 13:02:19 -0700 Subject: [PATCH 2/4] Fix type handling --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index a090713..25f546a 100644 --- a/main.go +++ b/main.go @@ -72,7 +72,7 @@ func main() { 0, cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { - if (*ignoreNormal && obj.(corev1.Event).Type == corev1.EventTypeNormal) { + if (*ignoreNormal && obj.(*corev1.Event).Type == corev1.EventTypeNormal) { return } j, _ := json.Marshal(obj) From d7fb1ad0f1251256455c0a0442330ea271ab9578 Mon Sep 17 00:00:00 2001 From: Max Williams <8859277+max-rocket-internet@users.noreply.github.com> Date: Thu, 6 Jul 2023 12:13:12 +0200 Subject: [PATCH 3/4] Update main.go --- main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/main.go b/main.go index 9998ad9..cbaa434 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "encoding/json" "flag" - "fmt" "log" "os" From 8a02ca1eedc28abf0304626d90c0bd3733d156a4 Mon Sep 17 00:00:00 2001 From: Max Williams <8859277+max-rocket-internet@users.noreply.github.com> Date: Thu, 6 Jul 2023 12:18:56 +0200 Subject: [PATCH 4/4] Update main.go --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index cbaa434..1c93243 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,7 @@ import ( ) var ( - ignoreNormal = flag.Bool("ignore_normal", false, "ignore events of the normal type, they can be noisy") + ignoreNormal = flag.Bool("ignore-normal", false, "ignore events of type 'Normal' to reduce noise") ) func main() {