mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-09-27 01:56:03 +08:00
use non-string context key
This commit is contained in:
@@ -16,7 +16,12 @@ import (
|
||||
authorizationv1 "k8s.io/api/authorization/v1"
|
||||
)
|
||||
|
||||
const ClientContextKey = "client"
|
||||
type key int
|
||||
|
||||
const (
|
||||
// ContextClientKey is the key used to identify the Client value in Context
|
||||
ContextClientKey key = iota
|
||||
)
|
||||
|
||||
func getBearerToken(ctx context.Context) (*string, bool) {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
@@ -60,7 +65,7 @@ func getClient(ctx context.Context, kubeConfig *v1.Config, db *v1.DB) (context.C
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return context.WithValue(ctx, ClientContextKey, client), nil
|
||||
return context.WithValue(ctx, ContextClientKey, client), nil
|
||||
}
|
||||
|
||||
func IsAuthorized(c *v1.Client, namespace, verb, group, resource, name string) (allowed bool, err error) {
|
||||
|
Reference in New Issue
Block a user