mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 16:42:26 +08:00
Chore: Remove result field from remaining datasources queries (#65054)
remove result field from datasources
This commit is contained in:
@ -19,7 +19,7 @@ type DataSourceService interface {
|
||||
GetDataSources(ctx context.Context, query *GetDataSourcesQuery) ([]*DataSource, error)
|
||||
|
||||
// GetAllDataSources gets all datasources.
|
||||
GetAllDataSources(ctx context.Context, query *GetAllDataSourcesQuery) error
|
||||
GetAllDataSources(ctx context.Context, query *GetAllDataSourcesQuery) (res []*DataSource, err error)
|
||||
|
||||
// GetDataSourcesByType gets datasources by type.
|
||||
GetDataSourcesByType(ctx context.Context, query *GetDataSourcesByTypeQuery) ([]*DataSource, error)
|
||||
|
@ -41,9 +41,8 @@ func (s *FakeDataSourceService) GetDataSources(ctx context.Context, query *datas
|
||||
return dataSources, nil
|
||||
}
|
||||
|
||||
func (s *FakeDataSourceService) GetAllDataSources(ctx context.Context, query *datasources.GetAllDataSourcesQuery) error {
|
||||
query.Result = s.DataSources
|
||||
return nil
|
||||
func (s *FakeDataSourceService) GetAllDataSources(ctx context.Context, query *datasources.GetAllDataSourcesQuery) (res []*datasources.DataSource, err error) {
|
||||
return s.DataSources, nil
|
||||
}
|
||||
|
||||
func (s *FakeDataSourceService) GetDataSourcesByType(ctx context.Context, query *datasources.GetDataSourcesByTypeQuery) ([]*datasources.DataSource, error) {
|
||||
|
@ -157,9 +157,7 @@ type GetDataSourcesQuery struct {
|
||||
User *user.SignedInUser
|
||||
}
|
||||
|
||||
type GetAllDataSourcesQuery struct {
|
||||
Result []*DataSource
|
||||
}
|
||||
type GetAllDataSourcesQuery struct{}
|
||||
|
||||
type GetDataSourcesByTypeQuery struct {
|
||||
OrgID int64 // optional: filter by org_id
|
||||
|
@ -161,7 +161,7 @@ func (s *Service) GetDataSources(ctx context.Context, query *datasources.GetData
|
||||
return s.SQLStore.GetDataSources(ctx, query)
|
||||
}
|
||||
|
||||
func (s *Service) GetAllDataSources(ctx context.Context, query *datasources.GetAllDataSourcesQuery) error {
|
||||
func (s *Service) GetAllDataSources(ctx context.Context, query *datasources.GetAllDataSourcesQuery) (res []*datasources.DataSource, err error) {
|
||||
return s.SQLStore.GetAllDataSources(ctx, query)
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ type Store interface {
|
||||
DeleteDataSource(context.Context, *datasources.DeleteDataSourceCommand) error
|
||||
AddDataSource(context.Context, *datasources.AddDataSourceCommand) (*datasources.DataSource, error)
|
||||
UpdateDataSource(context.Context, *datasources.UpdateDataSourceCommand) (*datasources.DataSource, error)
|
||||
GetAllDataSources(ctx context.Context, query *datasources.GetAllDataSourcesQuery) error
|
||||
GetAllDataSources(ctx context.Context, query *datasources.GetAllDataSourcesQuery) (res []*datasources.DataSource, err error)
|
||||
|
||||
Count(context.Context, *quota.ScopeParameters) (*quota.Map, error)
|
||||
}
|
||||
@ -93,11 +93,12 @@ func (ss *SqlStore) GetDataSources(ctx context.Context, query *datasources.GetDa
|
||||
})
|
||||
}
|
||||
|
||||
func (ss *SqlStore) GetAllDataSources(ctx context.Context, query *datasources.GetAllDataSourcesQuery) error {
|
||||
return ss.db.WithDbSession(ctx, func(sess *db.Session) error {
|
||||
query.Result = make([]*datasources.DataSource, 0)
|
||||
return sess.Asc("name").Find(&query.Result)
|
||||
func (ss *SqlStore) GetAllDataSources(ctx context.Context, query *datasources.GetAllDataSourcesQuery) (res []*datasources.DataSource, err error) {
|
||||
err = ss.db.WithDbSession(ctx, func(sess *db.Session) error {
|
||||
res = make([]*datasources.DataSource, 0)
|
||||
return sess.Asc("name").Find(&res)
|
||||
})
|
||||
return res, err
|
||||
}
|
||||
|
||||
// GetDataSourcesByType returns all datasources for a given type or an error if the specified type is an empty string
|
||||
|
@ -55,12 +55,12 @@ func (s *DataSourceSecretMigrationService) Migrate(ctx context.Context) error {
|
||||
if needCompatibility || needMigration {
|
||||
logger.Debug("performing secret migration", "needs migration", needMigration, "needs compatibility", needCompatibility)
|
||||
query := &datasources.GetAllDataSourcesQuery{}
|
||||
err := s.dataSourcesService.GetAllDataSources(ctx, query)
|
||||
dsList, err := s.dataSourcesService.GetAllDataSources(ctx, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, ds := range query.Result {
|
||||
for _, ds := range dsList {
|
||||
secureJsonData, err := s.dataSourcesService.DecryptedValues(ctx, ds)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -43,12 +43,12 @@ func (c *dsCache) refreshCache(ctx context.Context) error {
|
||||
defaultDS := make(map[int64]*dsVal, 0)
|
||||
|
||||
q := &datasources.GetAllDataSourcesQuery{}
|
||||
err := c.ds.GetAllDataSources(ctx, q)
|
||||
dsList, err := c.ds.GetAllDataSources(ctx, q)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, ds := range q.Result {
|
||||
for _, ds := range dsList {
|
||||
val := &dsVal{
|
||||
InternalID: ds.ID,
|
||||
Name: ds.Name,
|
||||
|
Reference in New Issue
Block a user