From 9c1a4c16bb866336205b851efd034ffdad4d5be2 Mon Sep 17 00:00:00 2001 From: Valentin Fedoskin Date: Mon, 25 May 2020 11:16:33 +0200 Subject: [PATCH] simplify notifier --- pkg/notifier/notifier.go | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/pkg/notifier/notifier.go b/pkg/notifier/notifier.go index bc12504..411c8a9 100644 --- a/pkg/notifier/notifier.go +++ b/pkg/notifier/notifier.go @@ -1,45 +1,11 @@ package notifier import ( - "fmt" "github.com/fluxcd/flux/pkg/event" "github.com/sirupsen/logrus" - "strings" ) func notify(e event.Event) { - switch e.Type { - case event.EventSync: - processSyncEvent(e) - break - case event.EventCommit: - processCommitEvent(e) - default: - logrus.WithField("event", e).Error("unknown event type") - } - logrus.WithField("event-obj", e). - WithField("event-str", e.String()). - Debug("received event") -} - -func processCommitEvent(e event.Event) { - metadata := e.Metadata.(*event.CommitEventMetadata) - logrus.WithField(e.Type, e.ServiceIDs). - WithField("spec", metadata.Spec.Spec). - Info("received event") -} - -func processSyncEvent(e event.Event) { - metadata := e.Metadata.(*event.SyncEventMetadata) - logrus.WithField(e.Type, e.ServiceIDs). - WithField("errors", formatErrors(metadata.Errors)). - Info("received event") -} - -func formatErrors(errors []event.ResourceError) string { - list := make([]string, len(errors)) - for i := range errors { - list[i] = fmt.Sprintf("%s: %s", errors[i].ID, errors[i].Error) - } - return strings.Join(list, ",") + logrus.WithField("event", e.String()).Info("received event") + logrus.WithField("event", e).Debug("received event") }