mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AlertingMigration: Separate info into multiple annos (#33641)
This commit is contained in:
parent
6b0417207d
commit
57d46ea991
@ -72,18 +72,25 @@ func (a *alertRule) makeVersion() *alertRuleVersion {
|
||||
}
|
||||
}
|
||||
|
||||
func getMigrationInfo(da dashAlert) string {
|
||||
func addMigrationInfo(da *dashAlert) map[string]string {
|
||||
annotations := da.ParsedSettings.AlertRuleTags
|
||||
if annotations == nil {
|
||||
annotations = make(map[string]string, 3)
|
||||
}
|
||||
|
||||
annotations["__dashboardUid__"] = da.DashboardUID
|
||||
annotations["__panelId__"] = fmt.Sprintf("%v", da.PanelId)
|
||||
annotations["__alertId__"] = fmt.Sprintf("%v", da.Id)
|
||||
|
||||
return annotations
|
||||
}
|
||||
|
||||
func getMigrationString(da dashAlert) string {
|
||||
return fmt.Sprintf(`{"dashboardUid": "%v", "panelId": %v, "alertId": %v}`, da.DashboardUID, da.PanelId, da.Id)
|
||||
}
|
||||
|
||||
func (m *migration) makeAlertRule(cond condition, da dashAlert, folderUID string) (*alertRule, error) {
|
||||
migAnnotation := getMigrationInfo(da)
|
||||
|
||||
annotations := da.ParsedSettings.AlertRuleTags
|
||||
if annotations == nil {
|
||||
annotations = make(map[string]string, 1)
|
||||
}
|
||||
annotations["__migration__info__"] = migAnnotation
|
||||
annotations := addMigrationInfo(&da)
|
||||
|
||||
ar := &alertRule{
|
||||
OrgId: da.OrgId,
|
||||
|
@ -113,7 +113,7 @@ func (m *migration) Exec(sess *xorm.Session, mg *migrator.Migrator) error {
|
||||
switch {
|
||||
case dash.HasAcl:
|
||||
// create folder and assign the permissions of the dashboard (included default and inherited)
|
||||
ptr, err := m.createFolder(dash.OrgId, fmt.Sprintf(DASHBOARD_FOLDER, getMigrationInfo(da)))
|
||||
ptr, err := m.createFolder(dash.OrgId, fmt.Sprintf(DASHBOARD_FOLDER, getMigrationString(da)))
|
||||
if err != nil {
|
||||
return MigrationError{
|
||||
Err: fmt.Errorf("failed to create folder: %w", err),
|
||||
|
Loading…
Reference in New Issue
Block a user