Chore: Move identity and errutil to apimachinery module (#89116)
This commit is contained in:
@@ -3,7 +3,7 @@ package user
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/grafana/grafana/pkg/util/errutil"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/errutil"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user