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