clientcontext

package
v0.0.0-...-4315425 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetadataURLFormat   = "%s/%s/v1/metadata/services"
	EventsURLFormat     = "%s/%s/v1/events"
	EventsInfoURLFormat = "%s/%s/v1/events/subscribed"

	RuntimeDefaultCommonName = "*Runtime*"
)
View Source
const (
	// ApplicationHeader is key representing Application in headers
	ApplicationHeader = "Application"

	// ApplicationContextKey is the key value for storing Application in context
	ApplicationContextKey clientContextKey = "ApplicationContext"

	// ApiURLsKey is the key value for storing API hosts in context
	ApiURLsKey clientContextKey = "ApiURLs"

	// ClusterContextKey is the key value for storing cluster data in context
	ClusterContextKey clientContextKey = "ClusterContext"

	// TenantHeader is key representing Tenant in headers
	TenantHeader = "Tenant"

	// GroupHeader is key representing Group in headers
	GroupHeader = "Group"

	// GroupEmpty represents empty value for Group
	GroupEmpty = ""

	// TenantEmpty represents empty value for Tenant
	TenantEmpty = ""

	// ApplicationEmpty represents empty value for Application
	ApplicationEmpty = ""

	// LookupEnabled represents value for required fetch from Runtime
	LookupEnabled LookupEnabledType = true

	// LookupDisabled represents value for not required fetch from Runtime
	LookupDisabled LookupEnabledType = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiURLs

type ApiURLs struct {
	EventsBaseURL   string
	MetadataBaseURL string
}

func (ApiURLs) ExtendContext

func (r ApiURLs) ExtendContext(ctx context.Context) context.Context

ExtendContext extends provided context with ApiURLs

type ApplicationContext

type ApplicationContext struct {
	Application string `json:"application"`
	ClusterContext
}

func ExtractApplicationContext

func ExtractApplicationContext(ctx context.Context) (ApplicationContext, apperrors.AppError)

func (ApplicationContext) ExtendContext

func (appCtx ApplicationContext) ExtendContext(ctx context.Context) context.Context

ExtendContext extends provided context with ApplicationContext

func (ApplicationContext) GetApplication

func (appCtx ApplicationContext) GetApplication() string

GetApplication returns Application identifier

func (ApplicationContext) GetLogger

func (appCtx ApplicationContext) GetLogger() *logrus.Entry

GetLogger returns context logger with embedded context data (Application, Group and Tenant)

func (ApplicationContext) GetRuntimeUrls

func (appCtx ApplicationContext) GetRuntimeUrls() *RuntimeURLs

GetRuntimeUrls returns nil as ApplicationContext does not contain RuntimeURLs

func (ApplicationContext) IsEmpty

func (appCtx ApplicationContext) IsEmpty() bool

IsEmpty returns false if Application is set

type ApplicationContextExtractor

type ApplicationContextExtractor func(ctx context.Context) (ApplicationContext, apperrors.AppError)

type ClientCertContextService

type ClientCertContextService interface {
	ClientContextService
	ClientContext() ClientContextService
	GetSubject() certificates.CSRSubject
}

type ClientContextService

type ClientContextService interface {
	GetRuntimeUrls() *RuntimeURLs
	GetLogger() *logrus.Entry
}

type ClusterContext

type ClusterContext struct {
	Group  string `json:"group,omitempty"`
	Tenant string `json:"tenant,omitempty"`
}

func (ClusterContext) ExtendContext

func (clsCtx ClusterContext) ExtendContext(ctx context.Context) context.Context

ExtendContext extends provided context with ClusterContext

func (ClusterContext) GetLogger

func (clsCtx ClusterContext) GetLogger() *logrus.Entry

GetLogger returns context logger with embedded context data (Group and Tenant)

func (ClusterContext) GetRuntimeUrls

func (clsCtx ClusterContext) GetRuntimeUrls() *RuntimeURLs

GetRuntimeUrls returns nil as ClusterContext does not contain RuntimeURLs

func (ClusterContext) IsEmpty

func (clsCtx ClusterContext) IsEmpty() bool

IsEmpty returns false if both Group and Tenant are set

type ClusterContextStrategy

type ClusterContextStrategy interface {
	ReadClusterContextFromRequest(r *http.Request) ClusterContext
	IsValidContext(clusterCtx ClusterContext) bool
}

func NewClusterContextStrategy

func NewClusterContextStrategy(clusterContextEnabled CtxEnabledType) ClusterContextStrategy

type ConnectorClientExtractor

type ConnectorClientExtractor func(ctx context.Context) (ClientCertContextService, apperrors.AppError)

type ContextExtender

type ContextExtender interface {
	ExtendContext(ctx context.Context) context.Context
}

func NewApplicationContextExtender

func NewApplicationContextExtender() ContextExtender

NewApplicationContextExtender returns empty ApplicationContext

func NewClusterContextExtender

func NewClusterContextExtender() ContextExtender

NewClusterContextExtender creates empty ClusterContext

type ContextExtractor

type ContextExtractor struct {
	// contains filtered or unexported fields
}

func NewContextExtractor

func NewContextExtractor(subjectDefaults certificates.CSRSubject) *ContextExtractor

func (*ContextExtractor) CreateApplicationClientContextService

func (ext *ContextExtractor) CreateApplicationClientContextService(ctx context.Context) (ClientCertContextService, apperrors.AppError)

func (*ContextExtractor) CreateClusterClientContextService

func (ext *ContextExtractor) CreateClusterClientContextService(ctx context.Context) (ClientCertContextService, apperrors.AppError)

type CtxEnabledType

type CtxEnabledType bool

CtxEnabledType type defines if context is enabled

type ExtendedApplicationContext

type ExtendedApplicationContext struct {
	ApplicationContext
	RuntimeURLs
}

func (ExtendedApplicationContext) GetRuntimeUrls

func (extAppCtx ExtendedApplicationContext) GetRuntimeUrls() *RuntimeURLs

GetRuntimeUrls returns pointer to RuntimeURLs

func (ExtendedApplicationContext) MarshalJSON

func (extAppCtx ExtendedApplicationContext) MarshalJSON() ([]byte, error)

MarshalJSON marshals ExtendedApplicationContext to JSON as ApplicationContext

type LookupEnabledType

type LookupEnabledType bool

LookupEnabledType type defines if headers must be specified

type RuntimeURLs

type RuntimeURLs struct {
	EventsInfoURL string `json:"eventsInfoUrl"`
	EventsURL     string `json:"eventsUrl"`
	MetadataURL   string `json:"metadataUrl"`
}

Directories

Path Synopsis
Code generated by mockery v1.0.0.
Code generated by mockery v1.0.0.

Jump to

Keyboard shortcuts

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