Chore: Remove context.TODO() (#43409)
* Remove context.TODO() from services * Fix live test * Remove context.TODO
This commit is contained in:
@@ -373,7 +373,7 @@ func (s *testRenderService) RenderErrorImage(theme rendering.Theme, err error) (
|
||||
return &rendering.RenderResult{FilePath: "image.png"}, nil
|
||||
}
|
||||
|
||||
func (s *testRenderService) GetRenderUser(key string) (*rendering.RenderUser, bool) {
|
||||
func (s *testRenderService) GetRenderUser(ctx context.Context, key string) (*rendering.RenderUser, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ func (ks *keySetHTTP) getJWKS(ctx context.Context) (keySetJWKS, error) {
|
||||
var jwks keySetJWKS
|
||||
|
||||
if ks.cacheExpiration > 0 {
|
||||
if val, err := ks.cache.Get(ks.cacheKey); err == nil {
|
||||
if val, err := ks.cache.Get(ctx, ks.cacheKey); err == nil {
|
||||
err := json.Unmarshal(val.([]byte), &jwks)
|
||||
return jwks, err
|
||||
}
|
||||
@@ -200,7 +200,7 @@ func (ks *keySetHTTP) getJWKS(ctx context.Context) (keySetJWKS, error) {
|
||||
}
|
||||
|
||||
if ks.cacheExpiration > 0 {
|
||||
err = ks.cache.Set(ks.cacheKey, jsonBuf.Bytes(), ks.cacheExpiration)
|
||||
err = ks.cache.Set(ctx, ks.cacheKey, jsonBuf.Bytes(), ks.cacheExpiration)
|
||||
}
|
||||
return jwks, err
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ func TestInitContextWithAuthProxy_CachedInvalidUserID(t *testing.T) {
|
||||
key := fmt.Sprintf(authproxy.CachePrefix, h)
|
||||
|
||||
t.Logf("Injecting stale user ID in cache with key %q", key)
|
||||
err = svc.RemoteCache.Set(key, int64(33), 0)
|
||||
err = svc.RemoteCache.Set(context.Background(), key, int64(33), 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
authEnabled := svc.initContextWithAuthProxy(ctx, orgID)
|
||||
@@ -76,7 +76,7 @@ func TestInitContextWithAuthProxy_CachedInvalidUserID(t *testing.T) {
|
||||
require.Equal(t, userID, ctx.SignedInUser.UserId)
|
||||
require.True(t, ctx.IsSignedIn)
|
||||
|
||||
i, err := svc.RemoteCache.Get(key)
|
||||
i, err := svc.RemoteCache.Get(context.Background(), key)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, userID, i.(int64))
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ func (auth *AuthProxy) GetUserViaCache(logger log.Logger) (int64, error) {
|
||||
return 0, err
|
||||
}
|
||||
logger.Debug("Getting user ID via auth cache", "cacheKey", cacheKey)
|
||||
userID, err := auth.remoteCache.Get(cacheKey)
|
||||
userID, err := auth.remoteCache.Get(auth.ctx.Req.Context(), cacheKey)
|
||||
if err != nil {
|
||||
logger.Debug("Failed getting user ID via auth cache", "error", err)
|
||||
return 0, err
|
||||
@@ -221,7 +221,7 @@ func (auth *AuthProxy) RemoveUserFromCache(logger log.Logger) error {
|
||||
return err
|
||||
}
|
||||
logger.Debug("Removing user from auth cache", "cacheKey", cacheKey)
|
||||
if err := auth.remoteCache.Delete(cacheKey); err != nil {
|
||||
if err := auth.remoteCache.Delete(auth.ctx.Req.Context(), cacheKey); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -349,14 +349,14 @@ func (auth *AuthProxy) Remember(id int64) error {
|
||||
}
|
||||
|
||||
// Check if user already in cache
|
||||
userID, err := auth.remoteCache.Get(key)
|
||||
userID, err := auth.remoteCache.Get(auth.ctx.Req.Context(), key)
|
||||
if err == nil && userID != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
expiration := time.Duration(auth.cfg.AuthProxySyncTTL) * time.Minute
|
||||
|
||||
if err := auth.remoteCache.Set(key, id, expiration); err != nil {
|
||||
if err := auth.remoteCache.Set(auth.ctx.Req.Context(), key, id, expiration); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ func TestMiddlewareContext(t *testing.T) {
|
||||
h, err := HashCacheKey(hdrName)
|
||||
require.NoError(t, err)
|
||||
key := fmt.Sprintf(CachePrefix, h)
|
||||
err = cache.Set(key, id, 0)
|
||||
err = cache.Set(context.Background(), key, id, 0)
|
||||
require.NoError(t, err)
|
||||
// Set up the middleware
|
||||
auth := prepareMiddleware(t, cache, nil)
|
||||
@@ -109,7 +109,7 @@ func TestMiddlewareContext(t *testing.T) {
|
||||
h, err := HashCacheKey(hdrName + "-" + group + "-" + role)
|
||||
require.NoError(t, err)
|
||||
key := fmt.Sprintf(CachePrefix, h)
|
||||
err = cache.Set(key, id, 0)
|
||||
err = cache.Set(context.Background(), key, id, 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
auth := prepareMiddleware(t, cache, func(req *http.Request, cfg *setting.Cfg) {
|
||||
|
||||
@@ -399,7 +399,7 @@ func (h *ContextHandler) initContextWithRenderAuth(reqContext *models.ReqContext
|
||||
span, _ := opentracing.StartSpanFromContext(reqContext.Req.Context(), "initContextWithRenderAuth")
|
||||
defer span.Finish()
|
||||
|
||||
renderUser, exists := h.RenderService.GetRenderUser(key)
|
||||
renderUser, exists := h.RenderService.GetRenderUser(reqContext.Req.Context(), key)
|
||||
if !exists {
|
||||
reqContext.JsonApiErr(401, "Invalid Render Key", nil)
|
||||
return true
|
||||
|
||||
@@ -376,7 +376,7 @@ func (s *FakeDashboardService) SaveDashboard(ctx context.Context, dto *SaveDashb
|
||||
}
|
||||
|
||||
func (s *FakeDashboardService) ImportDashboard(ctx context.Context, dto *SaveDashboardDTO) (*models.Dashboard, error) {
|
||||
return s.SaveDashboard(context.Background(), dto, true)
|
||||
return s.SaveDashboard(ctx, dto, true)
|
||||
}
|
||||
|
||||
func (s *FakeDashboardService) DeleteDashboard(ctx context.Context, dashboardId int64, orgId int64) error {
|
||||
|
||||
@@ -48,7 +48,7 @@ func (p *DataSourceProxyService) ProxyDataSourceRequest(c *models.ReqContext) {
|
||||
func (p *DataSourceProxyService) ProxyDatasourceRequestWithID(c *models.ReqContext, dsID int64) {
|
||||
c.TimeRequest(metrics.MDataSourceProxyReqTimer)
|
||||
|
||||
ds, err := p.DataSourceCache.GetDatasource(dsID, c.SignedInUser, c.SkipCache)
|
||||
ds, err := p.DataSourceCache.GetDatasource(c.Req.Context(), dsID, c.SignedInUser, c.SkipCache)
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceAccessDenied) {
|
||||
c.JsonApiErr(http.StatusForbidden, "Access denied to datasource", err)
|
||||
|
||||
@@ -18,7 +18,7 @@ func ProvideCacheService(cacheService *localcache.CacheService, sqlStore *sqlsto
|
||||
}
|
||||
|
||||
type CacheService interface {
|
||||
GetDatasource(datasourceID int64, user *models.SignedInUser, skipCache bool) (*models.DataSource, error)
|
||||
GetDatasource(ctx context.Context, datasourceID int64, user *models.SignedInUser, skipCache bool) (*models.DataSource, error)
|
||||
GetDatasourceByUID(ctx context.Context, datasourceUID string, user *models.SignedInUser, skipCache bool) (*models.DataSource, error)
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ type CacheServiceImpl struct {
|
||||
}
|
||||
|
||||
func (dc *CacheServiceImpl) GetDatasource(
|
||||
ctx context.Context,
|
||||
datasourceID int64,
|
||||
user *models.SignedInUser,
|
||||
skipCache bool,
|
||||
@@ -46,7 +47,7 @@ func (dc *CacheServiceImpl) GetDatasource(
|
||||
plog.Debug("Querying for data source via SQL store", "id", datasourceID, "orgId", user.OrgId)
|
||||
|
||||
query := &models.GetDataSourceQuery{Id: datasourceID, OrgId: user.OrgId}
|
||||
err := dc.SQLStore.GetDataSource(context.TODO(), query)
|
||||
err := dc.SQLStore.GetDataSource(ctx, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ func updateFolderACL(t *testing.T, sqlStore *sqlstore.SQLStore, folderID int64,
|
||||
})
|
||||
}
|
||||
|
||||
err := sqlStore.UpdateDashboardACL(folderID, aclItems)
|
||||
err := sqlStore.UpdateDashboardACL(context.Background(), folderID, aclItems)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -1462,7 +1462,7 @@ func updateFolderACL(t *testing.T, sqlStore *sqlstore.SQLStore, folderID int64,
|
||||
})
|
||||
}
|
||||
|
||||
err := sqlStore.UpdateDashboardACL(folderID, aclItems)
|
||||
err := sqlStore.UpdateDashboardACL(context.Background(), folderID, aclItems)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -41,7 +42,7 @@ func (srv TestingApiSrv) RouteTestRuleConfig(c *models.ReqContext, body apimodel
|
||||
|
||||
var path string
|
||||
if datasourceID, err := strconv.ParseInt(recipient, 10, 64); err == nil {
|
||||
ds, err := srv.DatasourceCache.GetDatasource(datasourceID, c.SignedInUser, c.SkipCache)
|
||||
ds, err := srv.DatasourceCache.GetDatasource(context.Background(), datasourceID, c.SignedInUser, c.SkipCache)
|
||||
if err != nil {
|
||||
return ErrResp(http.StatusInternalServerError, err, "failed to get datasource")
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func (am *LotexAM) withAMReq(
|
||||
extractor func(*response.NormalResponse) (interface{}, error),
|
||||
headers map[string]string,
|
||||
) response.Response {
|
||||
ds, err := am.DataProxy.DataSourceCache.GetDatasource(ctx.ParamsInt64(":Recipient"), ctx.SignedInUser, ctx.SkipCache)
|
||||
ds, err := am.DataProxy.DataSourceCache.GetDatasource(ctx.Req.Context(), ctx.ParamsInt64(":Recipient"), ctx.SignedInUser, ctx.SkipCache)
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceAccessDenied) {
|
||||
return ErrResp(http.StatusForbidden, err, "Access denied to datasource")
|
||||
|
||||
@@ -76,7 +76,7 @@ func (p *LotexProm) RouteGetRuleStatuses(ctx *models.ReqContext) response.Respon
|
||||
}
|
||||
|
||||
func (p *LotexProm) getEndpoints(ctx *models.ReqContext) (*promEndpoints, error) {
|
||||
ds, err := p.DataProxy.DataSourceCache.GetDatasource(ctx.ParamsInt64(":Recipient"), ctx.SignedInUser, ctx.SkipCache)
|
||||
ds, err := p.DataProxy.DataSourceCache.GetDatasource(ctx.Req.Context(), ctx.ParamsInt64(":Recipient"), ctx.SignedInUser, ctx.SkipCache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ func (r *LotexRuler) RoutePostNameRulesConfig(ctx *models.ReqContext, conf apimo
|
||||
}
|
||||
|
||||
func (r *LotexRuler) validateAndGetPrefix(ctx *models.ReqContext) (string, error) {
|
||||
ds, err := r.DataProxy.DataSourceCache.GetDatasource(ctx.ParamsInt64(":Recipient"), ctx.SignedInUser, ctx.SkipCache)
|
||||
ds, err := r.DataProxy.DataSourceCache.GetDatasource(ctx.Req.Context(), ctx.ParamsInt64(":Recipient"), ctx.SignedInUser, ctx.SkipCache)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func backendType(ctx *models.ReqContext, cache datasources.CacheService) (apimod
|
||||
return apimodels.GrafanaBackend, nil
|
||||
}
|
||||
if datasourceID, err := strconv.ParseInt(recipient, 10, 64); err == nil {
|
||||
if ds, err := cache.GetDatasource(datasourceID, ctx.SignedInUser, ctx.SkipCache); err == nil {
|
||||
if ds, err := cache.GetDatasource(ctx.Req.Context(), datasourceID, ctx.SignedInUser, ctx.SkipCache); err == nil {
|
||||
switch ds.Type {
|
||||
case "loki", "prometheus":
|
||||
return apimodels.LoTexRulerBackend, nil
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
type configReader interface {
|
||||
readConfig(path string) ([]*pluginsAsConfig, error)
|
||||
readConfig(ctx context.Context, path string) ([]*pluginsAsConfig, error)
|
||||
}
|
||||
|
||||
type configReaderImpl struct {
|
||||
@@ -26,7 +26,7 @@ func newConfigReader(logger log.Logger, pluginStore plugins.Store) configReader
|
||||
return &configReaderImpl{log: logger, pluginStore: pluginStore}
|
||||
}
|
||||
|
||||
func (cr *configReaderImpl) readConfig(path string) ([]*pluginsAsConfig, error) {
|
||||
func (cr *configReaderImpl) readConfig(ctx context.Context, path string) ([]*pluginsAsConfig, error) {
|
||||
var apps []*pluginsAsConfig
|
||||
cr.log.Debug("Looking for plugin provisioning files", "path", path)
|
||||
|
||||
@@ -57,7 +57,7 @@ func (cr *configReaderImpl) readConfig(path string) ([]*pluginsAsConfig, error)
|
||||
|
||||
checkOrgIDAndOrgName(apps)
|
||||
|
||||
err = cr.validatePluginsConfig(apps)
|
||||
err = cr.validatePluginsConfig(ctx, apps)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -107,14 +107,14 @@ func validateRequiredField(apps []*pluginsAsConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cr *configReaderImpl) validatePluginsConfig(apps []*pluginsAsConfig) error {
|
||||
func (cr *configReaderImpl) validatePluginsConfig(ctx context.Context, apps []*pluginsAsConfig) error {
|
||||
for i := range apps {
|
||||
if apps[i].Apps == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, app := range apps[i].Apps {
|
||||
if _, exists := cr.pluginStore.Plugin(context.TODO(), app.PluginID); !exists {
|
||||
if _, exists := cr.pluginStore.Plugin(ctx, app.PluginID); !exists {
|
||||
return fmt.Errorf("plugin not installed: %q", app.PluginID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,27 +21,27 @@ const (
|
||||
func TestConfigReader(t *testing.T) {
|
||||
t.Run("Broken yaml should return error", func(t *testing.T) {
|
||||
reader := newConfigReader(log.New("test logger"), nil)
|
||||
_, err := reader.readConfig(brokenYaml)
|
||||
_, err := reader.readConfig(context.Background(), brokenYaml)
|
||||
require.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("Skip invalid directory", func(t *testing.T) {
|
||||
cfgProvider := newConfigReader(log.New("test logger"), nil)
|
||||
cfg, err := cfgProvider.readConfig(emptyFolder)
|
||||
cfg, err := cfgProvider.readConfig(context.Background(), emptyFolder)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, cfg, 0)
|
||||
})
|
||||
|
||||
t.Run("Unknown app plugin should return error", func(t *testing.T) {
|
||||
cfgProvider := newConfigReader(log.New("test logger"), fakePluginStore{})
|
||||
_, err := cfgProvider.readConfig(unknownApp)
|
||||
_, err := cfgProvider.readConfig(context.Background(), unknownApp)
|
||||
require.Error(t, err)
|
||||
require.Equal(t, "plugin not installed: \"nonexisting\"", err.Error())
|
||||
})
|
||||
|
||||
t.Run("Read incorrect properties", func(t *testing.T) {
|
||||
cfgProvider := newConfigReader(log.New("test logger"), nil)
|
||||
_, err := cfgProvider.readConfig(incorrectSettings)
|
||||
_, err := cfgProvider.readConfig(context.Background(), incorrectSettings)
|
||||
require.Error(t, err)
|
||||
require.Equal(t, "app item 1 in configuration doesn't contain required field type", err.Error())
|
||||
})
|
||||
@@ -61,7 +61,7 @@ func TestConfigReader(t *testing.T) {
|
||||
})
|
||||
|
||||
cfgProvider := newConfigReader(log.New("test logger"), pm)
|
||||
cfg, err := cfgProvider.readConfig(correctProperties)
|
||||
cfg, err := cfgProvider.readConfig(context.Background(), correctProperties)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, cfg, 1)
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ func (ap *PluginProvisioner) apply(ctx context.Context, cfg *pluginsAsConfig) er
|
||||
}
|
||||
|
||||
func (ap *PluginProvisioner) applyChanges(ctx context.Context, configPath string) error {
|
||||
configs, err := ap.cfgProvider.readConfig(configPath)
|
||||
configs, err := ap.cfgProvider.readConfig(ctx, configPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -91,6 +91,6 @@ type testConfigReader struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func (tcr *testConfigReader) readConfig(path string) ([]*pluginsAsConfig, error) {
|
||||
func (tcr *testConfigReader) readConfig(ctx context.Context, path string) ([]*pluginsAsConfig, error) {
|
||||
return tcr.result, tcr.err
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ func (s *Service) getDataSourceFromQuery(ctx context.Context, user *models.Signe
|
||||
// use datasourceId if it exists
|
||||
id := query.Get("datasourceId").MustInt64(0)
|
||||
if id > 0 {
|
||||
ds, err = s.dataSourceCache.GetDatasource(id, user, skipCache)
|
||||
ds, err = s.dataSourceCache.GetDatasource(ctx, id, user, skipCache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -72,5 +72,5 @@ type Service interface {
|
||||
Render(ctx context.Context, opts Opts) (*RenderResult, error)
|
||||
RenderCSV(ctx context.Context, opts CSVOpts) (*RenderCSVResult, error)
|
||||
RenderErrorImage(theme Theme, error error) (*RenderResult, error)
|
||||
GetRenderUser(key string) (*RenderUser, bool)
|
||||
GetRenderUser(ctx context.Context, key string) (*RenderUser, bool)
|
||||
}
|
||||
|
||||
@@ -228,12 +228,12 @@ func (rs *RenderingService) render(ctx context.Context, opts Opts) (*RenderResul
|
||||
if math.IsInf(opts.DeviceScaleFactor, 0) || math.IsNaN(opts.DeviceScaleFactor) || opts.DeviceScaleFactor <= 0 {
|
||||
opts.DeviceScaleFactor = 1
|
||||
}
|
||||
renderKey, err := rs.generateAndStoreRenderKey(opts.OrgID, opts.UserID, opts.OrgRole)
|
||||
renderKey, err := rs.generateAndStoreRenderKey(ctx, opts.OrgID, opts.UserID, opts.OrgRole)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer rs.deleteRenderKey(renderKey)
|
||||
defer rs.deleteRenderKey(ctx, renderKey)
|
||||
|
||||
defer func() {
|
||||
metrics.MRenderingQueue.Set(float64(atomic.AddInt32(&rs.inProgressCount, -1)))
|
||||
@@ -263,12 +263,12 @@ func (rs *RenderingService) renderCSV(ctx context.Context, opts CSVOpts) (*Rende
|
||||
}
|
||||
|
||||
rs.log.Info("Rendering", "path", opts.Path)
|
||||
renderKey, err := rs.generateAndStoreRenderKey(opts.OrgID, opts.UserID, opts.OrgRole)
|
||||
renderKey, err := rs.generateAndStoreRenderKey(ctx, opts.OrgID, opts.UserID, opts.OrgRole)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer rs.deleteRenderKey(renderKey)
|
||||
defer rs.deleteRenderKey(ctx, renderKey)
|
||||
|
||||
defer func() {
|
||||
metrics.MRenderingQueue.Set(float64(atomic.AddInt32(&rs.inProgressCount, -1)))
|
||||
@@ -278,8 +278,8 @@ func (rs *RenderingService) renderCSV(ctx context.Context, opts CSVOpts) (*Rende
|
||||
return rs.renderCSVAction(ctx, renderKey, opts)
|
||||
}
|
||||
|
||||
func (rs *RenderingService) GetRenderUser(key string) (*RenderUser, bool) {
|
||||
val, err := rs.RemoteCacheService.Get(fmt.Sprintf(renderKeyPrefix, key))
|
||||
func (rs *RenderingService) GetRenderUser(ctx context.Context, key string) (*RenderUser, bool) {
|
||||
val, err := rs.RemoteCacheService.Get(ctx, fmt.Sprintf(renderKeyPrefix, key))
|
||||
if err != nil {
|
||||
rs.log.Error("Failed to get render key from cache", "error", err)
|
||||
}
|
||||
@@ -338,13 +338,13 @@ func (rs *RenderingService) getURL(path string) string {
|
||||
return fmt.Sprintf("%s://%s:%s%s/%s&render=1", protocol, rs.domain, rs.Cfg.HTTPPort, subPath, path)
|
||||
}
|
||||
|
||||
func (rs *RenderingService) generateAndStoreRenderKey(orgId, userId int64, orgRole models.RoleType) (string, error) {
|
||||
func (rs *RenderingService) generateAndStoreRenderKey(ctx context.Context, orgId, userId int64, orgRole models.RoleType) (string, error) {
|
||||
key, err := util.GetRandomString(32)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
err = rs.RemoteCacheService.Set(fmt.Sprintf(renderKeyPrefix, key), &RenderUser{
|
||||
err = rs.RemoteCacheService.Set(ctx, fmt.Sprintf(renderKeyPrefix, key), &RenderUser{
|
||||
OrgID: orgId,
|
||||
UserID: userId,
|
||||
OrgRole: string(orgRole),
|
||||
@@ -356,8 +356,8 @@ func (rs *RenderingService) generateAndStoreRenderKey(orgId, userId int64, orgRo
|
||||
return key, nil
|
||||
}
|
||||
|
||||
func (rs *RenderingService) deleteRenderKey(key string) {
|
||||
err := rs.RemoteCacheService.Delete(fmt.Sprintf(renderKeyPrefix, key))
|
||||
func (rs *RenderingService) deleteRenderKey(ctx context.Context, key string) {
|
||||
err := rs.RemoteCacheService.Delete(ctx, fmt.Sprintf(renderKeyPrefix, key))
|
||||
if err != nil {
|
||||
rs.log.Error("Failed to delete render key", "error", err)
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ func (ss *SQLStore) addDashboardACLQueryAndCommandHandlers() {
|
||||
bus.AddHandlerCtx("sql", ss.GetDashboardAclInfoList)
|
||||
}
|
||||
|
||||
func (ss *SQLStore) UpdateDashboardACL(dashboardID int64, items []*models.DashboardAcl) error {
|
||||
return ss.UpdateDashboardACLCtx(context.TODO(), dashboardID, items)
|
||||
func (ss *SQLStore) UpdateDashboardACL(ctx context.Context, dashboardID int64, items []*models.DashboardAcl) error {
|
||||
return ss.UpdateDashboardACLCtx(ctx, dashboardID, items)
|
||||
}
|
||||
|
||||
func (ss *SQLStore) UpdateDashboardACLCtx(ctx context.Context, dashboardID int64, items []*models.DashboardAcl) error {
|
||||
|
||||
@@ -70,7 +70,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
|
||||
|
||||
t.Run("Folder with removed default permissions returns no acl items", func(t *testing.T) {
|
||||
setup(t)
|
||||
err := sqlStore.UpdateDashboardACL(savedFolder.Id, nil)
|
||||
err := sqlStore.UpdateDashboardACL(context.Background(), savedFolder.Id, nil)
|
||||
require.Nil(t, err)
|
||||
|
||||
query := models.GetDashboardAclInfoListQuery{DashboardID: childDash.Id, OrgID: 1}
|
||||
|
||||
@@ -381,5 +381,5 @@ func testHelperUpdateDashboardAcl(t *testing.T, sqlStore *SQLStore, dashboardID
|
||||
item.Updated = time.Now()
|
||||
itemPtrs = append(itemPtrs, &item)
|
||||
}
|
||||
return sqlStore.UpdateDashboardACL(dashboardID, itemPtrs)
|
||||
return sqlStore.UpdateDashboardACL(context.Background(), dashboardID, itemPtrs)
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ func createDummyACL(t *testing.T, sqlStore *SQLStore, dashboardPermission *Dashb
|
||||
acl.Role = &dashboardPermission.Role
|
||||
}
|
||||
|
||||
err := sqlStore.UpdateDashboardACL(dashboardID, []*models.DashboardAcl{acl})
|
||||
err := sqlStore.UpdateDashboardACL(context.Background(), dashboardID, []*models.DashboardAcl{acl})
|
||||
require.NoError(t, err)
|
||||
if user != nil {
|
||||
return user.Id
|
||||
|
||||
Reference in New Issue
Block a user