mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Remove url based external alertmanagers config (#57918)
* Remove URL-based alertmanagers from endpoint config * WIP * Add migration and alertmanagers from admin_configuration * Empty comment removed * set BasicAuth true when user is present in url * Remove Alertmanagers from GET /admin_config payload * Remove URL-based alertmanager configuration from UI * Fix new uid generation in external alertmanagers migration * Fix tests for URL-based external alertmanagers * Fix API tests * Add more tests, move migration code to separate file, and remove possible am duplicate urls * Fix edge cases in migration * Fix imports * Remove useless fields and fix created_at/updated_at retrieval Co-authored-by: George Robinson <george.robinson@grafana.com> Co-authored-by: Konrad Lalik <konrad.lalik@grafana.com>
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type AlertmanagersChoice int
|
||||
@@ -26,9 +23,6 @@ type AdminConfiguration struct {
|
||||
ID int64 `xorm:"pk autoincr 'id'"`
|
||||
OrgID int64 `xorm:"org_id"`
|
||||
|
||||
// List of Alertmanager(s) URL to push alerts to.
|
||||
Alertmanagers []string
|
||||
|
||||
// SendAlertsTo indicates which set of alertmanagers will handle the alert.
|
||||
SendAlertsTo AlertmanagersChoice `xorm:"send_alerts_to"`
|
||||
|
||||
@@ -36,23 +30,6 @@ type AdminConfiguration struct {
|
||||
UpdatedAt int64 `xorm:"updated"`
|
||||
}
|
||||
|
||||
func (ac *AdminConfiguration) AsSHA256() string {
|
||||
h := sha256.New()
|
||||
_, _ = h.Write([]byte(fmt.Sprintf("%v", ac.Alertmanagers)))
|
||||
return fmt.Sprintf("%x", h.Sum(nil))
|
||||
}
|
||||
|
||||
func (ac *AdminConfiguration) Validate() error {
|
||||
for _, u := range ac.Alertmanagers {
|
||||
_, err := url.Parse(u)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// String implements the Stringer interface
|
||||
func (amc AlertmanagersChoice) String() string {
|
||||
return alertmanagersChoiceMap[amc]
|
||||
|
||||
Reference in New Issue
Block a user