Documentation ¶
Index ¶
- Constants
- func AuditEventFrom(ctx context.Context) *audit.Event
- func NamespaceFrom(ctx context.Context) (string, bool)
- func NamespaceValue(ctx context.Context) string
- func NewContext() context.Context
- func NewDefaultContext() context.Context
- func UserFrom(ctx context.Context) (user.Info, bool)
- func WithAuditEvent(parent context.Context, ev *audit.Event) context.Context
- func WithNamespace(parent context.Context, namespace string) context.Context
- func WithRequestInfo(parent context.Context, info *RequestInfo) context.Context
- func WithUser(parent context.Context, user user.Info) context.Context
- func WithValue(parent context.Context, key interface{}, val interface{}) context.Context
- type RequestInfo
- type RequestInfoFactory
- type RequestInfoResolver
Constants ¶
const ( GlobalScope = "Global" ClusterScope = "Cluster" WorkspaceScope = "Workspace" NamespaceScope = "Namespace" DevOpsScope = "DevOps" )
Variables ¶
This section is empty.
Functions ¶
func AuditEventFrom ¶
AuditEventFrom returns the audit event struct on the ctx
func NamespaceFrom ¶
NamespaceFrom returns the value of the namespace key on the ctx
func NamespaceValue ¶
NamespaceValue returns the value of the namespace key on the ctx, or the empty string if none
func NewContext ¶
NewContext instantiates a base context object for request flows.
func NewDefaultContext ¶
NewDefaultContext instantiates a base context object for request flows in the default namespace
func WithAuditEvent ¶
WithAuditEvent returns set audit event struct.
func WithNamespace ¶
WithNamespace returns a copy of parent in which the namespace value is set
func WithRequestInfo ¶
func WithRequestInfo(parent context.Context, info *RequestInfo) context.Context
Types ¶
type RequestInfo ¶
type RequestInfo struct { *k8srequest.RequestInfo // IsKubernetesRequest indicates whether or not the request should be handled by kubernetes or kubesphere IsKubernetesRequest bool // Workspace of requested resource, for non-workspaced resources, this may be empty Workspace string // Cluster of requested resource, this is empty in single-cluster environment Cluster string // DevOps project of requested resource DevOps string // Scope of requested resource. ResourceScope string // Source IP SourceIP string // User agent UserAgent string }
RequestInfo holds information parsed from the http.Request, extended from k8s.io/apiserver/pkg/endpoints/request/requestinfo.go
func RequestInfoFrom ¶
func RequestInfoFrom(ctx context.Context) (*RequestInfo, bool)
type RequestInfoFactory ¶
type RequestInfoFactory struct { APIPrefixes sets.String GrouplessAPIPrefixes sets.String GlobalResources []schema.GroupResource }
func (*RequestInfoFactory) NewRequestInfo ¶
func (r *RequestInfoFactory) NewRequestInfo(req *http.Request) (*RequestInfo, error)
NewRequestInfo returns the information from the http request. If error is not nil, RequestInfo holds the information as best it is known before the failure It handles both resource and non-resource requests and fills in all the pertinent information for each. Valid Inputs:
/apis/{api-group}/{version}/namespaces /api/{version}/namespaces /api/{version}/namespaces/{namespace} /api/{version}/namespaces/{namespace}/{resource} /api/{version}/namespaces/{namespace}/{resource}/{resourceName} /api/{version}/{resource} /api/{version}/{resource}/{resourceName}
Special verbs without subresources: /api/{version}/proxy/{resource}/{resourceName} /api/{version}/proxy/namespaces/{namespace}/{resource}/{resourceName}
Special verbs with subresources: /api/{version}/watch/{resource} /api/{version}/watch/namespaces/{namespace}/{resource}
/kapis/{api-group}/{version}/workspaces/{workspace}/{resource}/{resourceName} / /kapis/{api-group}/{version}/namespaces/{namespace}/{resource} /kapis/{api-group}/{version}/namespaces/{namespace}/{resource}/{resourceName} With workspaces: /kapis/clusters/{cluster}/{api-group}/{version}/namespaces/{namespace}/{resource} /kapis/clusters/{cluster}/{api-group}/{version}/namespaces/{namespace}/{resource}/{resourceName}
type RequestInfoResolver ¶
type RequestInfoResolver interface {
NewRequestInfo(req *http.Request) (*RequestInfo, error)
}