chore: remove sqlstore & mockstore dependencies from (most) packages (#57087)

* chore: add alias for InitTestDB and Session

Adds an alias for the sqlstore InitTestDB and Session, and updates tests using these to reduce dependencies on the sqlstore.Store.

* next pass of removing sqlstore imports
* last little bit
* remove mockstore where possible
This commit is contained in:
Kristin Laemmert
2022-10-19 09:02:15 -04:00
committed by GitHub
parent 5285d34cc0
commit 05709ce411
273 changed files with 1595 additions and 1491 deletions
+4 -4
View File
@@ -3,9 +3,9 @@ package searchV2
import (
"context"
"github.com/grafana/grafana/pkg/infra/db"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/services/sqlstore/permissions"
"github.com/grafana/grafana/pkg/services/sqlstore/searchstore"
"github.com/grafana/grafana/pkg/services/user"
@@ -22,7 +22,7 @@ type FutureAuthService interface {
var _ FutureAuthService = (*simpleSQLAuthService)(nil)
type simpleSQLAuthService struct {
sql *sqlstore.SQLStore
sql db.DB
ac accesscontrol.Service
}
@@ -35,7 +35,7 @@ func (a *simpleSQLAuthService) getDashboardTableAuthFilter(user *user.SignedInUs
return permissions.DashboardPermissionFilter{
OrgRole: user.OrgRole,
OrgId: user.OrgID,
Dialect: a.sql.Dialect,
Dialect: a.sql.GetDialect(),
UserId: user.UserID,
PermissionLevel: models.PERMISSION_VIEW,
}
@@ -48,7 +48,7 @@ func (a *simpleSQLAuthService) GetDashboardReadFilter(user *user.SignedInUser) (
filter := a.getDashboardTableAuthFilter(user)
rows := make([]*dashIdQueryResult, 0)
err := a.sql.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error {
err := a.sql.WithDbSession(context.Background(), func(sess *db.Session) error {
sql, params := filter.Where()
sess.Table("dashboard").
Where(sql, params...).