mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Rename DispatchCtx to Dispatch (#43563)
This commit is contained in:
@@ -84,7 +84,7 @@ func (provider *Provisioner) CleanUpOrphanedDashboards(ctx context.Context) {
|
||||
currentReaders[index] = reader.Cfg.Name
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &models.DeleteOrphanedProvisionedDashboardsCommand{ReaderNames: currentReaders}); err != nil {
|
||||
if err := bus.Dispatch(ctx, &models.DeleteOrphanedProvisionedDashboardsCommand{ReaderNames: currentReaders}); err != nil {
|
||||
provider.log.Warn("Failed to delete orphaned provisioned dashboards", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ func getOrCreateFolderID(ctx context.Context, cfg *config, service dashboards.Da
|
||||
}
|
||||
|
||||
cmd := &models.GetDashboardQuery{Slug: models.SlugifyTitle(folderName), OrgId: cfg.OrgID}
|
||||
err := bus.DispatchCtx(ctx, cmd)
|
||||
err := bus.Dispatch(ctx, cmd)
|
||||
|
||||
if err != nil && !errors.Is(err, models.ErrDashboardNotFound) {
|
||||
return 0, err
|
||||
|
||||
@@ -45,7 +45,7 @@ func (dc *DatasourceProvisioner) apply(ctx context.Context, cfg *configs) error
|
||||
|
||||
for _, ds := range cfg.Datasources {
|
||||
cmd := &models.GetDataSourceQuery{OrgId: ds.OrgID, Name: ds.Name}
|
||||
err := bus.DispatchCtx(ctx, cmd)
|
||||
err := bus.Dispatch(ctx, cmd)
|
||||
if err != nil && !errors.Is(err, models.ErrDataSourceNotFound) {
|
||||
return err
|
||||
}
|
||||
@@ -53,13 +53,13 @@ func (dc *DatasourceProvisioner) apply(ctx context.Context, cfg *configs) error
|
||||
if errors.Is(err, models.ErrDataSourceNotFound) {
|
||||
insertCmd := createInsertCommand(ds)
|
||||
dc.log.Info("inserting datasource from configuration ", "name", insertCmd.Name, "uid", insertCmd.Uid)
|
||||
if err := bus.DispatchCtx(ctx, insertCmd); err != nil {
|
||||
if err := bus.Dispatch(ctx, insertCmd); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
updateCmd := createUpdateCommand(ds, cmd.Result.Id)
|
||||
dc.log.Debug("updating datasource from configuration", "name", updateCmd.Name, "uid", updateCmd.Uid)
|
||||
if err := bus.DispatchCtx(ctx, updateCmd); err != nil {
|
||||
if err := bus.Dispatch(ctx, updateCmd); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ func (dc *DatasourceProvisioner) applyChanges(ctx context.Context, configPath st
|
||||
func (dc *DatasourceProvisioner) deleteDatasources(ctx context.Context, dsToDelete []*deleteDatasourceConfig) error {
|
||||
for _, ds := range dsToDelete {
|
||||
cmd := &models.DeleteDataSourceCommand{OrgID: ds.OrgID, Name: ds.Name}
|
||||
if err := bus.DispatchCtx(ctx, cmd); err != nil {
|
||||
if err := bus.Dispatch(ctx, cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func (dc *NotificationProvisioner) deleteNotifications(ctx context.Context, noti
|
||||
|
||||
if notification.OrgID == 0 && notification.OrgName != "" {
|
||||
getOrg := &models.GetOrgByNameQuery{Name: notification.OrgName}
|
||||
if err := bus.DispatchCtx(ctx, getOrg); err != nil {
|
||||
if err := bus.Dispatch(ctx, getOrg); err != nil {
|
||||
return err
|
||||
}
|
||||
notification.OrgID = getOrg.Result.Id
|
||||
@@ -58,13 +58,13 @@ func (dc *NotificationProvisioner) deleteNotifications(ctx context.Context, noti
|
||||
|
||||
getNotification := &models.GetAlertNotificationsWithUidQuery{Uid: notification.UID, OrgId: notification.OrgID}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, getNotification); err != nil {
|
||||
if err := bus.Dispatch(ctx, getNotification); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if getNotification.Result != nil {
|
||||
cmd := &models.DeleteAlertNotificationWithUidCommand{Uid: getNotification.Result.Uid, OrgId: getNotification.OrgId}
|
||||
if err := bus.DispatchCtx(ctx, cmd); err != nil {
|
||||
if err := bus.Dispatch(ctx, cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ func (dc *NotificationProvisioner) mergeNotifications(ctx context.Context, notif
|
||||
for _, notification := range notificationToMerge {
|
||||
if notification.OrgID == 0 && notification.OrgName != "" {
|
||||
getOrg := &models.GetOrgByNameQuery{Name: notification.OrgName}
|
||||
if err := bus.DispatchCtx(ctx, getOrg); err != nil {
|
||||
if err := bus.Dispatch(ctx, getOrg); err != nil {
|
||||
return err
|
||||
}
|
||||
notification.OrgID = getOrg.Result.Id
|
||||
@@ -86,7 +86,7 @@ func (dc *NotificationProvisioner) mergeNotifications(ctx context.Context, notif
|
||||
}
|
||||
|
||||
cmd := &models.GetAlertNotificationsWithUidQuery{OrgId: notification.OrgID, Uid: notification.UID}
|
||||
err := bus.DispatchCtx(ctx, cmd)
|
||||
err := bus.Dispatch(ctx, cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -106,7 +106,7 @@ func (dc *NotificationProvisioner) mergeNotifications(ctx context.Context, notif
|
||||
SendReminder: notification.SendReminder,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, insertCmd); err != nil {
|
||||
if err := bus.Dispatch(ctx, insertCmd); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
@@ -124,7 +124,7 @@ func (dc *NotificationProvisioner) mergeNotifications(ctx context.Context, notif
|
||||
SendReminder: notification.SendReminder,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, updateCmd); err != nil {
|
||||
if err := bus.Dispatch(ctx, updateCmd); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func (ap *PluginProvisioner) apply(ctx context.Context, cfg *pluginsAsConfig) er
|
||||
for _, app := range cfg.Apps {
|
||||
if app.OrgID == 0 && app.OrgName != "" {
|
||||
getOrgQuery := &models.GetOrgByNameQuery{Name: app.OrgName}
|
||||
if err := bus.DispatchCtx(ctx, getOrgQuery); err != nil {
|
||||
if err := bus.Dispatch(ctx, getOrgQuery); err != nil {
|
||||
return err
|
||||
}
|
||||
app.OrgID = getOrgQuery.Result.Id
|
||||
@@ -41,7 +41,7 @@ func (ap *PluginProvisioner) apply(ctx context.Context, cfg *pluginsAsConfig) er
|
||||
}
|
||||
|
||||
query := &models.GetPluginSettingByIdQuery{OrgId: app.OrgID, PluginId: app.PluginID}
|
||||
err := bus.DispatchCtx(ctx, query)
|
||||
err := bus.Dispatch(ctx, query)
|
||||
if err != nil {
|
||||
if !errors.Is(err, models.ErrPluginSettingNotFound) {
|
||||
return err
|
||||
@@ -60,7 +60,7 @@ func (ap *PluginProvisioner) apply(ctx context.Context, cfg *pluginsAsConfig) er
|
||||
SecureJsonData: app.SecureJSONData,
|
||||
PluginVersion: app.PluginVersion,
|
||||
}
|
||||
if err := bus.DispatchCtx(ctx, cmd); err != nil {
|
||||
if err := bus.Dispatch(ctx, cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func CheckOrgExists(ctx context.Context, orgID int64) error {
|
||||
query := models.GetOrgByIdQuery{Id: orgID}
|
||||
if err := bus.DispatchCtx(ctx, &query); err != nil {
|
||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
||||
if errors.Is(err, models.ErrOrgNotFound) {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user