Chore: Move identity and errutil to apimachinery module (#89116)

This commit is contained in:
Ryan McKinley
2024-06-13 07:11:35 +03:00
committed by GitHub
parent 12a45fdeca
commit 99d8025829
298 changed files with 575 additions and 393 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ package user
import (
"errors"
"github.com/grafana/grafana/pkg/util/errutil"
"github.com/grafana/grafana/pkg/apimachinery/errutil"
)
var (
+8 -7
View File
@@ -5,20 +5,21 @@ import (
"strconv"
"time"
"github.com/grafana/grafana/pkg/models/roletype"
"github.com/grafana/grafana/pkg/services/auth/identity"
"github.com/grafana/grafana/pkg/apimachinery/identity"
)
const (
GlobalOrgID = int64(0)
)
var _ identity.Requester = &SignedInUser{}
type SignedInUser struct {
UserID int64 `xorm:"user_id"`
UserUID string `xorm:"user_uid"`
OrgID int64 `xorm:"org_id"`
OrgName string
OrgRole roletype.RoleType
OrgRole identity.RoleType
Login string
Name string
Email string
@@ -57,7 +58,7 @@ func (u *SignedInUser) NameOrFallback() string {
return u.Email
}
func (u *SignedInUser) HasRole(role roletype.RoleType) bool {
func (u *SignedInUser) HasRole(role identity.RoleType) bool {
if u.IsGrafanaAdmin {
return true
}
@@ -97,7 +98,7 @@ func (u *SignedInUser) GetCacheKey() string {
// e.g. anonymous and render key.
orgRole := u.GetOrgRole()
if orgRole == "" {
orgRole = roletype.RoleNone
orgRole = identity.RoleNone
}
id = string(orgRole)
@@ -161,7 +162,7 @@ func (u *SignedInUser) GetTeams() []int64 {
}
// GetOrgRole returns the role of the active entity in the active organization
func (u *SignedInUser) GetOrgRole() roletype.RoleType {
func (u *SignedInUser) GetOrgRole() identity.RoleType {
return u.OrgRole
}
@@ -172,7 +173,7 @@ func (u *SignedInUser) GetID() identity.NamespaceID {
}
// GetNamespacedID returns the namespace and ID of the active entity
// The namespace is one of the constants defined in pkg/services/auth/identity
// The namespace is one of the constants defined in pkg/apimachinery/identity
func (u *SignedInUser) GetNamespacedID() (identity.Namespace, string) {
switch {
case u.ApiKeyID != 0:
+1 -1
View File
@@ -3,7 +3,7 @@ package user
import (
"time"
"github.com/grafana/grafana/pkg/services/auth/identity"
"github.com/grafana/grafana/pkg/apimachinery/identity"
"github.com/grafana/grafana/pkg/services/search/model"
)
+1 -1
View File
@@ -3,9 +3,9 @@ package user
import (
"unicode"
"github.com/grafana/grafana/pkg/apimachinery/errutil"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/util/errutil"
)
var (
+1 -1
View File
@@ -7,6 +7,7 @@ import (
"net/mail"
"time"
"github.com/grafana/grafana/pkg/apimachinery/errutil"
"github.com/grafana/grafana/pkg/services/auth"
"github.com/grafana/grafana/pkg/services/authn"
"github.com/grafana/grafana/pkg/services/notifications"
@@ -14,7 +15,6 @@ import (
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/util/errutil"
)
var (
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/grafana/grafana/pkg/services/auth/identity"
"github.com/grafana/grafana/pkg/apimachinery/identity"
"github.com/grafana/grafana/pkg/services/auth/idtest"
"github.com/grafana/grafana/pkg/services/notifications"
tempuser "github.com/grafana/grafana/pkg/services/temp_user"