Chore: Move ReqContext to contexthandler service (#62102)

* Chore: Move ReqContext to contexthandler service

* Rename package to contextmodel

* Generate ngalert files

* Remove unused imports
This commit is contained in:
idafurjes
2023-01-27 08:50:36 +01:00
committed by GitHub
parent 8379a29b53
commit 6c5a573772
180 changed files with 1208 additions and 1182 deletions
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"fmt"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
grpccontext "github.com/grafana/grafana/pkg/services/grpcserver/context"
"github.com/grafana/grafana/pkg/services/user"
)
@@ -33,7 +33,7 @@ func User(ctx context.Context) (*user.SignedInUser, error) {
}
// Set by incoming HTTP request
c, ok := ctxkey.Get(ctx).(*models.ReqContext)
c, ok := ctxkey.Get(ctx).(*contextmodel.ReqContext)
if ok && c.SignedInUser != nil {
return c.SignedInUser, nil
}
+2 -2
View File
@@ -8,8 +8,8 @@ import (
"github.com/grafana/grafana/pkg/infra/appcontext"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
grpccontext "github.com/grafana/grafana/pkg/services/grpcserver/context"
"github.com/grafana/grafana/pkg/services/user"
"github.com/stretchr/testify/require"
@@ -47,7 +47,7 @@ func TestUserFromContext(t *testing.T) {
t.Run("should return user set by HTTP ReqContext", func(t *testing.T) {
expected := testUser()
ctx := ctxkey.Set(context.Background(), &models.ReqContext{
ctx := ctxkey.Set(context.Background(), &contextmodel.ReqContext{
SignedInUser: expected,
})
actual, err := appcontext.User(ctx)