Fire event after datasource delete (#38090)

This commit is contained in:
Travis Patterson
2021-08-20 14:51:31 -06:00
committed by GitHub
parent b88f8bacf3
commit 32e11434da
3 changed files with 44 additions and 0 deletions
+10
View File
@@ -5,6 +5,7 @@ import (
"strings"
"time"
"github.com/grafana/grafana/pkg/events"
"github.com/grafana/grafana/pkg/util/errutil"
"github.com/grafana/grafana/pkg/components/simplejson"
@@ -145,6 +146,15 @@ func DeleteDataSource(cmd *models.DeleteDataSourceCommand) error {
return inTransaction(func(sess *DBSession) error {
result, err := sess.Exec(params...)
cmd.DeletedDatasourcesCount, _ = result.RowsAffected()
sess.publishAfterCommit(&events.DataSourceDeleted{
Timestamp: time.Now(),
Name: cmd.Name,
ID: cmd.ID,
UID: cmd.UID,
OrgID: cmd.OrgID,
})
return err
})
}