mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Make identity.Requester available at Context * Clean pkg/services/guardian/guardian.go * Clean guardian provider and guardian AC * Clean pkg/api/team.go * Clean ctxhandler, datasources, plugin and live * Clean dashboards and guardian * Implement NewUserDisplayDTOFromRequester * Change status code numbers for http constants * Upgrade signature of ngalert services * log parsing errors instead of throwing error
33 lines
936 B
Go
33 lines
936 B
Go
package datasources
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/services/auth/identity"
|
|
"github.com/grafana/grafana/pkg/services/datasources"
|
|
)
|
|
|
|
type FakeCacheService struct {
|
|
DataSources []*datasources.DataSource
|
|
}
|
|
|
|
var _ datasources.CacheService = &FakeCacheService{}
|
|
|
|
func (c *FakeCacheService) GetDatasource(ctx context.Context, datasourceID int64, user identity.Requester, skipCache bool) (*datasources.DataSource, error) {
|
|
for _, datasource := range c.DataSources {
|
|
if datasource.ID == datasourceID {
|
|
return datasource, nil
|
|
}
|
|
}
|
|
return nil, datasources.ErrDataSourceNotFound
|
|
}
|
|
|
|
func (c *FakeCacheService) GetDatasourceByUID(ctx context.Context, datasourceUID string, user identity.Requester, skipCache bool) (*datasources.DataSource, error) {
|
|
for _, datasource := range c.DataSources {
|
|
if datasource.UID == datasourceUID {
|
|
return datasource, nil
|
|
}
|
|
}
|
|
return nil, datasources.ErrDataSourceNotFound
|
|
}
|