Move SignedInUser to user service and RoleType and Roles to org (#53445)
* Move SignedInUser to user service and RoleType and Roles to org * Use go naming convention for roles * Fix some imports and leftovers * Fix ldap debug test * Fix lint * Fix lint 2 * Fix lint 3 * Fix type and not needed conversion * Clean up messages in api tests * Clean up api tests 2
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
sdkhttpclient "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/httpclient"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
)
|
||||
|
||||
// DataSourceService interface for interacting with datasources.
|
||||
@@ -59,8 +59,8 @@ type DataSourceService interface {
|
||||
// CacheService interface for retrieving a cached datasource.
|
||||
type CacheService interface {
|
||||
// GetDatasource gets a datasource identified by datasource numeric identifier.
|
||||
GetDatasource(ctx context.Context, datasourceID int64, user *models.SignedInUser, skipCache bool) (*DataSource, error)
|
||||
GetDatasource(ctx context.Context, datasourceID int64, user *user.SignedInUser, skipCache bool) (*DataSource, error)
|
||||
|
||||
// GetDatasourceByUID gets a datasource identified by datasource unique identifier (UID).
|
||||
GetDatasourceByUID(ctx context.Context, datasourceUID string, user *models.SignedInUser, skipCache bool) (*DataSource, error)
|
||||
GetDatasourceByUID(ctx context.Context, datasourceUID string, user *user.SignedInUser, skipCache bool) (*DataSource, error)
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package datasources
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
)
|
||||
|
||||
type FakeCacheService struct {
|
||||
@@ -13,7 +13,7 @@ type FakeCacheService struct {
|
||||
|
||||
var _ datasources.CacheService = &FakeCacheService{}
|
||||
|
||||
func (c *FakeCacheService) GetDatasource(ctx context.Context, datasourceID int64, user *models.SignedInUser, skipCache bool) (*datasources.DataSource, error) {
|
||||
func (c *FakeCacheService) GetDatasource(ctx context.Context, datasourceID int64, user *user.SignedInUser, skipCache bool) (*datasources.DataSource, error) {
|
||||
for _, datasource := range c.DataSources {
|
||||
if datasource.Id == datasourceID {
|
||||
return datasource, nil
|
||||
@@ -22,7 +22,7 @@ func (c *FakeCacheService) GetDatasource(ctx context.Context, datasourceID int64
|
||||
return nil, datasources.ErrDataSourceNotFound
|
||||
}
|
||||
|
||||
func (c *FakeCacheService) GetDatasourceByUID(ctx context.Context, datasourceUID string, user *models.SignedInUser, skipCache bool) (*datasources.DataSource, error) {
|
||||
func (c *FakeCacheService) GetDatasourceByUID(ctx context.Context, datasourceUID string, user *user.SignedInUser, skipCache bool) (*datasources.DataSource, error) {
|
||||
for _, datasource := range c.DataSources {
|
||||
if datasource.Uid == datasourceUID {
|
||||
return datasource, nil
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -156,7 +156,7 @@ type UpdateSecretFn func() error
|
||||
type GetDataSourcesQuery struct {
|
||||
OrgId int64
|
||||
DataSourceLimit int
|
||||
User *models.SignedInUser
|
||||
User *user.SignedInUser
|
||||
Result []*DataSource
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ type GetDataSourcesByTypeQuery struct {
|
||||
|
||||
type GetDefaultDataSourceQuery struct {
|
||||
OrgId int64
|
||||
User *models.SignedInUser
|
||||
User *user.SignedInUser
|
||||
Result *DataSource
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ func (p DsPermissionType) String() string {
|
||||
}
|
||||
|
||||
type DatasourcesPermissionFilterQuery struct {
|
||||
User *models.SignedInUser
|
||||
User *user.SignedInUser
|
||||
Datasources []*DataSource
|
||||
Result []*DataSource
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
)
|
||||
|
||||
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)
|
||||
FilterDatasourceUidsBasedOnQueryPermissions(ctx context.Context, user *user.SignedInUser, datasourceUids []string) ([]string, error)
|
||||
}
|
||||
|
||||
// dummy method
|
||||
@@ -20,7 +20,7 @@ func (hs *OSSDatasourcePermissionsService) FilterDatasourcesBasedOnQueryPermissi
|
||||
return ErrNotImplemented
|
||||
}
|
||||
|
||||
func (hs *OSSDatasourcePermissionsService) FilterDatasourceUidsBasedOnQueryPermissions(ctx context.Context, user *models.SignedInUser, datasourceUids []string) ([]string, error) {
|
||||
func (hs *OSSDatasourcePermissionsService) FilterDatasourceUidsBasedOnQueryPermissions(ctx context.Context, user *user.SignedInUser, datasourceUids []string) ([]string, error) {
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package permissions
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
)
|
||||
|
||||
type mockDatasourcePermissionService struct {
|
||||
@@ -13,7 +13,7 @@ type mockDatasourcePermissionService struct {
|
||||
ErrResult error
|
||||
}
|
||||
|
||||
func (m *mockDatasourcePermissionService) FilterDatasourceUidsBasedOnQueryPermissions(ctx context.Context, user *models.SignedInUser, datasourceUids []string) ([]string, error) {
|
||||
func (m *mockDatasourcePermissionService) FilterDatasourceUidsBasedOnQueryPermissions(ctx context.Context, user *user.SignedInUser, datasourceUids []string) ([]string, error) {
|
||||
return m.DsUidResult, m.ErrResult
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/localcache"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -35,7 +35,7 @@ type CacheServiceImpl struct {
|
||||
func (dc *CacheServiceImpl) GetDatasource(
|
||||
ctx context.Context,
|
||||
datasourceID int64,
|
||||
user *models.SignedInUser,
|
||||
user *user.SignedInUser,
|
||||
skipCache bool,
|
||||
) (*datasources.DataSource, error) {
|
||||
cacheKey := idKey(datasourceID)
|
||||
@@ -69,7 +69,7 @@ func (dc *CacheServiceImpl) GetDatasource(
|
||||
func (dc *CacheServiceImpl) GetDatasourceByUID(
|
||||
ctx context.Context,
|
||||
datasourceUID string,
|
||||
user *models.SignedInUser,
|
||||
user *user.SignedInUser,
|
||||
skipCache bool,
|
||||
) (*datasources.DataSource, error) {
|
||||
if datasourceUID == "" {
|
||||
|
||||
Reference in New Issue
Block a user