chore: remove errSkipNotification
This commit is contained in:
parent
a428a61fc3
commit
1bc747c18b
2 changed files with 7 additions and 10 deletions
|
@ -10,10 +10,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
errSkipNotification = errors.New("notification skipped")
|
|
||||||
)
|
|
||||||
|
|
||||||
type Handler interface {
|
type Handler interface {
|
||||||
ProduceNotifications(r *http.Request) ([]Notification, error)
|
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)
|
nots, err := b.h.ProduceNotifications(r)
|
||||||
|
|
||||||
if errors.Is(err, errSkipNotification) {
|
|
||||||
w.WriteHeader(http.StatusNoContent)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("failed to format notification")
|
slog.Error("failed to format notification")
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(nots) == 0 {
|
||||||
|
slog.Debug("no notification produced")
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, not := range nots {
|
for _, not := range nots {
|
||||||
not.topic = b.topic
|
not.topic = b.topic
|
||||||
not.auth = b.auth
|
not.auth = b.auth
|
||||||
|
|
|
@ -63,7 +63,7 @@ func (f FluxHandler) ProduceNotifications(r *http.Request) ([]Notification, erro
|
||||||
if not.Reason == "ReconciliationSucceeded" {
|
if not.Reason == "ReconciliationSucceeded" {
|
||||||
if ok := f.reconciliations[obj]; !ok {
|
if ok := f.reconciliations[obj]; !ok {
|
||||||
// Filter out spammy ReconciliationSucceeded notification
|
// Filter out spammy ReconciliationSucceeded notification
|
||||||
return nil, errSkipNotification
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// we will print the object so skip it next time it spam
|
// we will print the object so skip it next time it spam
|
||||||
|
|
Loading…
Reference in a new issue