From 467088567055b7bfa3f35905290095fc52f4b594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Thu, 30 Apr 2020 17:27:31 +0200 Subject: [PATCH] Expose more events --- internal/controller.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/controller.go b/internal/controller.go index a41ae5d4..da73f7d7 100644 --- a/internal/controller.go +++ b/internal/controller.go @@ -29,6 +29,9 @@ const ( // SuccessSynced is used as part of the Event 'reason' when a GrafanaDashboard is synced SuccessSynced = "Synced" + // WarningNotSynced is used as part of the Event 'reason' when a GrafanaDashboard could not be synced + WarningNotSynced = "Not synced" + // MessageResourceSynced is the message used for an Event fired when a GrafanaDashboard // is synced successfully MessageResourceSynced = "GrafanaDashboard synced successfully" @@ -229,6 +232,7 @@ func (c *Controller) syncHandler(key string) error { // processing. if errors.IsNotFound(err) { utilruntime.HandleError(fmt.Errorf("dashboard '%s' in work queue no longer exists", key)) + c.recorder.Event(dashboard, corev1.EventTypeWarning, WarningNotSynced, fmt.Sprintf("dashboard '%s' in work queue no longer exists", key)) return nil } @@ -237,6 +241,7 @@ func (c *Controller) syncHandler(key string) error { if err := c.dashboardCreator.FromRawSpec(dashboard.Folder, dashboard.ObjectMeta.Name, dashboard.Spec.Raw); err != nil { utilruntime.HandleError(fmt.Errorf("could not create dashboard from spec: %w", err)) + c.recorder.Event(dashboard, corev1.EventTypeWarning, WarningNotSynced, fmt.Sprintf("could not create dashboard from spec: %s", err)) return nil }