Skip to content

Commit

Permalink
Merge pull request #16 from K-Phoen/more-events
Browse files Browse the repository at this point in the history
Expose more events
  • Loading branch information
K-Phoen committed Apr 30, 2020
2 parents e74c99c + 4670885 commit 79cb84d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down

0 comments on commit 79cb84d

Please sign in to comment.