Skip to content

Commit

Permalink
Allow filtering out normal events (#31)
Browse files Browse the repository at this point in the history
* Allow filtering out normal events

* Fix type handling

* Update main.go

* Update main.go

---------

Co-authored-by: Max Williams <[email protected]>
  • Loading branch information
mmckeen and max-rocket-internet authored Jul 6, 2023
1 parent 9eb8df6 commit a12102d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"flag"
"log"
"os"

Expand All @@ -12,7 +13,13 @@ import (
"k8s.io/client-go/tools/clientcmd"
)

var (
ignoreNormal = flag.Bool("ignore-normal", false, "ignore events of type 'Normal' to reduce noise")
)

func main() {
flag.Parse()

loggerApplication := log.New(os.Stderr, "", log.LstdFlags)
loggerEvent := log.New(os.Stdout, "", 0)

Expand Down Expand Up @@ -51,6 +58,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))
},
Expand Down

0 comments on commit a12102d

Please sign in to comment.