Alerting: Add endpoint to revert to a previous alertmanager configuration (#65751)
* Alerting: Add endpoint to revert to a previous alertmanager configuration This endpoint is meant to be used in conjunction with /api/alertmanager/grafana/config/history to revert to a previously applied alertmanager configuration. This is done by ID instead of raw config string in order to avoid secure field complications.
This commit is contained in:
@@ -154,6 +154,21 @@ func (f *fakeConfigStore) GetAppliedConfigurations(_ context.Context, orgID int6
|
||||
return configs, nil
|
||||
}
|
||||
|
||||
func (f *fakeConfigStore) GetHistoricalConfiguration(_ context.Context, orgID int64, id int64) (*models.HistoricAlertConfiguration, error) {
|
||||
configsByOrg, ok := f.historicConfigs[orgID]
|
||||
if !ok {
|
||||
return &models.HistoricAlertConfiguration{}, store.ErrNoAlertmanagerConfiguration
|
||||
}
|
||||
|
||||
for _, conf := range configsByOrg {
|
||||
if conf.ID == id && conf.OrgID == orgID {
|
||||
return conf, nil
|
||||
}
|
||||
}
|
||||
|
||||
return &models.HistoricAlertConfiguration{}, store.ErrNoAlertmanagerConfiguration
|
||||
}
|
||||
|
||||
type FakeOrgStore struct {
|
||||
orgs []int64
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user