chore: remove errSkipNotification

This commit is contained in:
Bastien Riviere 2023-09-11 18:47:25 +02:00
parent a428a61fc3
commit 1bc747c18b
Signed by: babariviere
GPG key ID: 4E5F0839249F162E
2 changed files with 7 additions and 10 deletions

View file

@ -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

View file

@ -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