-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor GrafanaAlertmanager to not depend on Grafana #19
Conversation
type Notifier = notify.Notifier | ||
|
||
// Configuration is an interface for accessing Alertmanager configuration. | ||
type Configuration interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the biggest piece of this work - we've abstracted everything that could be Grafana-specific in an interface, there's probably more than will either go to Grafana or come back here but I've tried to do the minimum for now to get something done.
@@ -135,7 +112,32 @@ type MaintenanceOptions interface { | |||
MaintenanceFunc() (int64, error) | |||
} | |||
|
|||
type Template = template.Template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -21,11 +22,17 @@ var ( | |||
ErrGetAlertGroupsBadPayload = fmt.Errorf("unable to retrieve alerts groups") | |||
) | |||
|
|||
func (am *GrafanaAlertmanager) GetAlerts(active, silenced, inhibited bool, filter []string, receivers string) (apimodels.GettableAlerts, error) { | |||
type GettableAlerts = amv2.GettableAlerts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will be a better place to organise this, but for now, I want to make the diffs minimal until we know for sure that this works for Grafana. Then we can refactor away at our liking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, let's go!
This is the first substantial PR at decoupling the Alertmanager logic from the Grafana-specific logic - you can reference that by the removal of the Grafana-based imports from the code and the scope of an interface for that specific logic.
There's a LOT more work TODO (hence the number of comments in the code), but these should be followed up immediately and are very obvious that things don't work. For the ones that we think would be more long term and I'm happy to create an issue to track them.