injectproxy

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: Apache-2.0 Imports: 28 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustLabelValue added in v0.6.0

func MustLabelValue(ctx context.Context) string

MustLabelValue returns the first (alphabetical order) label value previously stored using WithLabelValue() from the given context. Similar to MustLabelValues, it will panic if no label is found or the value is empty.

func MustLabelValues added in v0.7.0

func MustLabelValues(ctx context.Context) []string

MustLabelValues returns labels (previously stored using WithLabelValue()) from the given context. It will panic if no label is found or the value is empty.

func NewRoutes

func NewRoutes(upstream *url.URL, label string, extractLabeler ExtractLabeler, opts ...Option) (*routes, error)

func WithLabelValues added in v0.7.0

func WithLabelValues(ctx context.Context, labels []string) context.Context

WithLabelValues stores labels in the given context.

Types

type Enforcer added in v0.2.0

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

func NewEnforcer added in v0.2.0

func NewEnforcer(errorOnReplace bool, ms ...*labels.Matcher) *Enforcer

func (Enforcer) EnforceMatchers added in v0.4.0

func (ms Enforcer) EnforceMatchers(targets []*labels.Matcher) ([]*labels.Matcher, error)

EnforceMatchers appends the configured label matcher if not present. If the label matcher that is to be injected is present (by labelname) but different (either by match type or value) the behavior depends on the errorOnReplace variable and the enforced matcher(s): * if errorOnReplace is true, an error is returned, * if errorOnReplace is false and the label matcher type is '=', the existing matcher is silently replaced. * otherwise the existing matcher is preserved.

func (Enforcer) EnforceNode added in v0.2.0

func (ms Enforcer) EnforceNode(node parser.Node) error

EnforceNode walks the given node recursively and enforces the given label enforcer on it.

Whenever a parser.MatrixSelector or parser.VectorSelector AST node is found, their label enforcer is being potentially modified. If a node's label matcher has the same name as a label matcher of the given enforcer, then it will be replaced.

type ExtractLabeler added in v0.6.0

type ExtractLabeler interface {
	ExtractLabel(next http.HandlerFunc) http.Handler
}

ExtractLabeler is an HTTP handler that extract the label value to be enforced from the HTTP request. If a valid label value is found, it should store it in the request's context. Otherwise it should return an error in the HTTP response (usually 400 or 500).

type HTTPFormEnforcer added in v0.6.0

type HTTPFormEnforcer struct {
	ParameterName string
}

HTTPFormEnforcer enforces a label value extracted from the HTTP form and query parameters.

func (HTTPFormEnforcer) ExtractLabel added in v0.6.0

func (hff HTTPFormEnforcer) ExtractLabel(next http.HandlerFunc) http.Handler

ExtractLabel implements the ExtractLabeler interface.

type HTTPHeaderEnforcer added in v0.6.0

type HTTPHeaderEnforcer struct {
	Name string
}

HTTPHeaderEnforcer enforces a label value extracted from the HTTP headers.

func (HTTPHeaderEnforcer) ExtractLabel added in v0.6.0

func (hhe HTTPHeaderEnforcer) ExtractLabel(next http.HandlerFunc) http.Handler

ExtractLabel implements the ExtractLabeler interface.

type IllegalLabelMatcherError added in v0.4.0

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

func (IllegalLabelMatcherError) Error added in v0.4.0

func (e IllegalLabelMatcherError) Error() string

type Option added in v0.3.0

type Option interface {
	// contains filtered or unexported methods
}

func WithEnabledLabelsAPI added in v0.3.0

func WithEnabledLabelsAPI() Option

WithEnabledLabelsAPI enables proxying to labels API. If false, "501 Not implemented" will be return for those.

func WithErrorOnReplace added in v0.4.0

func WithErrorOnReplace() Option

WithErrorOnReplace causes the proxy to return 400 if a label matcher we want to inject is present in the query already and matches something different

func WithPassthroughPaths added in v0.3.0

func WithPassthroughPaths(paths []string) Option

WithPassthroughPaths configures routes to register given paths as passthrough handlers for all HTTP methods. that, if requested, will be forwarded without enforcing label. Use with care. NOTE: Passthrough "all" paths like "/" or "" and regex are not allowed.

func WithPrometheusRegistry added in v0.6.0

func WithPrometheusRegistry(reg prometheus.Registerer) Option

WithPrometheusRegistry configures the proxy to use the given registerer.

func WithRegexMatch added in v0.8.0

func WithRegexMatch() Option

WithRegexMatch causes the proxy to handle tenant name as regexp

type StaticLabelEnforcer added in v0.6.0

type StaticLabelEnforcer []string

StaticLabelEnforcer enforces a static label value.

func (StaticLabelEnforcer) ExtractLabel added in v0.6.0

func (sle StaticLabelEnforcer) ExtractLabel(next http.HandlerFunc) http.Handler

ExtractLabel implements the ExtractLabeler interface.

Jump to

Keyboard shortcuts

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