mirror of
https://github.com/grafana/grafana.git
synced 2025-09-24 13:03:53 +08:00
Chore: Collect elasticsearch version usage stats (#31787)
* Chore: Collect elasticsearch version usage stats * Fix lint error * use GetDataSources from sqlstore * Apply review suggestions * Return error if datasource type is not specified * Update pkg/services/sqlstore/datasource.go * fix undefined var
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package sqlstore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -18,6 +19,7 @@ import (
|
||||
|
||||
func init() {
|
||||
bus.AddHandler("sql", GetDataSources)
|
||||
bus.AddHandler("sql", GetDataSourcesByType)
|
||||
bus.AddHandler("sql", GetDataSource)
|
||||
bus.AddHandler("sql", AddDataSource)
|
||||
bus.AddHandler("sql", DeleteDataSource)
|
||||
@ -71,10 +73,21 @@ func GetDataSources(query *models.GetDataSourcesQuery) error {
|
||||
} else {
|
||||
sess = x.Limit(query.DataSourceLimit, 0).Where("org_id=?", query.OrgId).Asc("name")
|
||||
}
|
||||
|
||||
query.Result = make([]*models.DataSource, 0)
|
||||
return sess.Find(&query.Result)
|
||||
}
|
||||
|
||||
// GetDataSourcesByType returns all datasources for a given type or an error if the specified type is an empty string
|
||||
func GetDataSourcesByType(query *models.GetDataSourcesByTypeQuery) error {
|
||||
if query.Type == "" {
|
||||
return fmt.Errorf("datasource type cannot be empty")
|
||||
}
|
||||
|
||||
query.Result = make([]*models.DataSource, 0)
|
||||
return x.Where("type=?", query.Type).Asc("id").Find(&query.Result)
|
||||
}
|
||||
|
||||
// GetDefaultDataSource is used to get the default datasource of organization
|
||||
func GetDefaultDataSource(query *models.GetDefaultDataSourceQuery) error {
|
||||
datasource := models.DataSource{}
|
||||
|
Reference in New Issue
Block a user