Skip to content

Commit a12102d

Browse files
Allow filtering out normal events (max-rocket-internet#31)
* Allow filtering out normal events * Fix type handling * Update main.go * Update main.go --------- Co-authored-by: Max Williams <[email protected]>
1 parent 9eb8df6 commit a12102d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"encoding/json"
5+
"flag"
56
"log"
67
"os"
78

@@ -12,7 +13,13 @@ import (
1213
"k8s.io/client-go/tools/clientcmd"
1314
)
1415

16+
var (
17+
ignoreNormal = flag.Bool("ignore-normal", false, "ignore events of type 'Normal' to reduce noise")
18+
)
19+
1520
func main() {
21+
flag.Parse()
22+
1623
loggerApplication := log.New(os.Stderr, "", log.LstdFlags)
1724
loggerEvent := log.New(os.Stdout, "", 0)
1825

@@ -51,6 +58,9 @@ func main() {
5158
0,
5259
cache.ResourceEventHandlerFuncs{
5360
AddFunc: func(obj interface{}) {
61+
if (*ignoreNormal && obj.(*corev1.Event).Type == corev1.EventTypeNormal) {
62+
return
63+
}
5464
j, _ := json.Marshal(obj)
5565
loggerEvent.Printf("%s\n", string(j))
5666
},

0 commit comments

Comments
 (0)