diff --git a/bridge/bridge.go b/bridge/bridge.go index 29b7b2d..7c350bd 100644 --- a/bridge/bridge.go +++ b/bridge/bridge.go @@ -10,10 +10,6 @@ import ( "strings" ) -var ( - errSkipNotification = errors.New("notification skipped") -) - type Handler interface { ProduceNotifications(r *http.Request) ([]Notification, error) } @@ -168,17 +164,18 @@ func (b Bridge) ServeHTTP(w http.ResponseWriter, r *http.Request) { nots, err := b.h.ProduceNotifications(r) - if errors.Is(err, errSkipNotification) { - w.WriteHeader(http.StatusNoContent) - return - } - if err != nil { slog.Error("failed to format notification") w.WriteHeader(http.StatusBadRequest) return } + if len(nots) == 0 { + slog.Debug("no notification produced") + w.WriteHeader(http.StatusNoContent) + return + } + for _, not := range nots { not.topic = b.topic not.auth = b.auth diff --git a/bridge/flux.go b/bridge/flux.go index 0088240..8f9bc9f 100644 --- a/bridge/flux.go +++ b/bridge/flux.go @@ -63,7 +63,7 @@ func (f FluxHandler) ProduceNotifications(r *http.Request) ([]Notification, erro if not.Reason == "ReconciliationSucceeded" { if ok := f.reconciliations[obj]; !ok { // Filter out spammy ReconciliationSucceeded notification - return nil, errSkipNotification + return nil, nil } // we will print the object so skip it next time it spam