mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 12:14:08 -06:00
Datasources: add datasourceUids
filter
This commit is contained in:
parent
4a12d0f236
commit
33fc3a683b
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
)
|
||||
|
||||
@ -11,6 +12,7 @@ var ErrNotImplemented = errors.New("not implemented")
|
||||
|
||||
type DatasourcePermissionsService interface {
|
||||
FilterDatasourcesBasedOnQueryPermissions(ctx context.Context, cmd *datasources.DatasourcesPermissionFilterQuery) error
|
||||
FilterDatasourceUidsBasedOnQueryPermissions(ctx context.Context, user *models.SignedInUser, datasourceUids []string) ([]string, error)
|
||||
}
|
||||
|
||||
// dummy method
|
||||
@ -18,6 +20,10 @@ func (hs *OSSDatasourcePermissionsService) FilterDatasourcesBasedOnQueryPermissi
|
||||
return ErrNotImplemented
|
||||
}
|
||||
|
||||
func (hs *OSSDatasourcePermissionsService) FilterDatasourceUidsBasedOnQueryPermissions(ctx context.Context, user *models.SignedInUser, datasourceUids []string) ([]string, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
type OSSDatasourcePermissionsService struct{}
|
||||
|
||||
func ProvideDatasourcePermissionsService() *OSSDatasourcePermissionsService {
|
||||
|
@ -3,12 +3,18 @@ package permissions
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
)
|
||||
|
||||
type mockDatasourcePermissionService struct {
|
||||
DsResult []*datasources.DataSource
|
||||
ErrResult error
|
||||
DsResult []*datasources.DataSource
|
||||
DsUidResult []string
|
||||
ErrResult error
|
||||
}
|
||||
|
||||
func (m *mockDatasourcePermissionService) FilterDatasourceUidsBasedOnQueryPermissions(ctx context.Context, user *models.SignedInUser, datasourceUids []string) ([]string, error) {
|
||||
return m.DsUidResult, m.ErrResult
|
||||
}
|
||||
|
||||
func (m *mockDatasourcePermissionService) FilterDatasourcesBasedOnQueryPermissions(ctx context.Context, cmd *datasources.DatasourcesPermissionFilterQuery) error {
|
||||
|
Loading…
Reference in New Issue
Block a user