clientcontext

package
v0.0.0-...-1ac4f16 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetadataURLFormat = "https://%s/%s/v1/metadata/services"
	EventsURLFormat   = "https://%s/%s/v1/events"
)
View Source
const (
	TenantPlaceholder      = "{TENANT}"
	GroupPlaceholder       = "{GROUP}"
	ApplicationPlaceholder = "{APPLICATION}"

	// ApplicationHeader is key representing Application in headers
	ApplicationHeader = "Application"

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

	// SubjectHeader is key representing client certificate subject set in headers
	SubjectHeader = "Client-Certificate-Subject"

	// APIHostsKey is the key value for storing API hosts in context
	APIHostsKey clientContextKey = "APIHosts"

	// 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"

	// SubjectCNSeparator holds separator for values packed in CN of Subject
	SubjectCNSeparator = ";"

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

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

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

	// CtxRequired represents value for required context
	CtxRequired CtxRequiredType = true

	// CtxNotRequired represents value for not required context
	CtxNotRequired CtxRequiredType = false

	// HeadersRequired represents value for required headers
	HeadersRequired HeadersRequiredType = true

	// HeadersNotRequired represents value for not required headers
	HeadersNotRequired HeadersRequiredType = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIHosts

type APIHosts struct {
	EventsHost   string
	MetadataHost string
}

func (APIHosts) ExtendContext

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

ExtendContext extends provided context with APIHosts

type ApplicationContext

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

func (ApplicationContext) ExtendContext

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

ExtendContext extends provided context with ApplicationContext

func (ApplicationContext) FillPlaceholders

func (appCtx ApplicationContext) FillPlaceholders(format string) string

FillPlaceholders replaces placeholders {TENANT}, {GROUP} and {APPLICATION} with values from the context

func (ApplicationContext) GetApplication

func (appCtx ApplicationContext) GetApplication() string

GetApplication returns Application identifier

func (ApplicationContext) GetCommonName

func (appCtx ApplicationContext) GetCommonName() string

GetCommonName returns expected Common Name value for the Application

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 ClientContextService

type ClientContextService interface {
	GetCommonName() string
	GetRuntimeUrls() *RuntimeURLs
	GetLogger() *logrus.Entry
	FillPlaceholders(format string) string
}

func CreateApplicationClientContextService

func CreateApplicationClientContextService(ctx context.Context) (ClientContextService, apperrors.AppError)

func CreateClusterClientContextService

func CreateClusterClientContextService(ctx context.Context) (ClientContextService, apperrors.AppError)

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

func (clsCtx ClusterContext) FillPlaceholders(format string) string

FillPlaceholders replaces placeholders {TENANT}, {GROUP} with values from the context

func (ClusterContext) GetCommonName

func (clsCtx ClusterContext) GetCommonName() string

GetCommonName returns expected Common Name value for the Cluster

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 ConnectorClientExtractor

type ConnectorClientExtractor func(ctx context.Context) (ClientContextService, 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 CtxRequiredType

type CtxRequiredType bool

CtxRequiredType type defines if context is mandatory

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 HeadersRequiredType

type HeadersRequiredType bool

HeadersRequiredType type defines if headers must be specified

type RuntimeURLs

type RuntimeURLs struct {
	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