request

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2021 License: Apache-2.0 Imports: 16 Imported by: 9

Documentation

Index

Constants

View Source
const (
	GlobalScope    = "Global"
	ClusterScope   = "Cluster"
	WorkspaceScope = "Workspace"
	NamespaceScope = "Namespace"
	DevOpsScope    = "DevOps"
)

Variables

This section is empty.

Functions

func AuditEventFrom

func AuditEventFrom(ctx context.Context) *audit.Event

AuditEventFrom returns the audit event struct on the ctx

func NamespaceFrom

func NamespaceFrom(ctx context.Context) (string, bool)

NamespaceFrom returns the value of the namespace key on the ctx

func NamespaceValue

func NamespaceValue(ctx context.Context) string

NamespaceValue returns the value of the namespace key on the ctx, or the empty string if none

func NewContext

func NewContext() context.Context

NewContext instantiates a base context object for request flows.

func NewDefaultContext

func NewDefaultContext() context.Context

NewDefaultContext instantiates a base context object for request flows in the default namespace

func UserFrom

func UserFrom(ctx context.Context) (user.Info, bool)

UserFrom returns the value of the user key on the ctx

func WithAuditEvent

func WithAuditEvent(parent context.Context, ev *audit.Event) context.Context

WithAuditEvent returns set audit event struct.

func WithNamespace

func WithNamespace(parent context.Context, namespace string) context.Context

WithNamespace returns a copy of parent in which the namespace value is set

func WithRequestInfo

func WithRequestInfo(parent context.Context, info *RequestInfo) context.Context

func WithUser

func WithUser(parent context.Context, user user.Info) context.Context

WithUser returns a copy of parent in which the user value is set

func WithValue

func WithValue(parent context.Context, key interface{}, val interface{}) context.Context

WithValue returns a copy of parent in which the value associated with key is val.

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
}

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)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL