selectors

package
v0.1.2-rc.3 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Companion package for github.com/fluxninja/aperture/api/gen/proto/go/aperture/policy/language/v1 containing convertions of proto-generated struct into golang ones and other helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MMExprFromLabelMatcher

func MMExprFromLabelMatcher(lm *labelmatcherv1.LabelMatcher) (mm.Expr, error)

MMExprFromLabelMatcher translates proto definition of label matcher into a // single multimatcher expression

LabelMatcher can be nil or a validated LabelMatcher.

func MMExprFromProto

func MMExprFromProto(expr *labelmatcherv1.MatchExpression) (mm.Expr, error)

MMExprFromProto converts proto definition of expression into multimatcher Expression

The expr is assumed to be validated and nonnil.

Types

type ControlPoint

type ControlPoint struct {
	// FIXME(FLUX-2362) Stop hardcoding "envoy vs feature" (?)
	// either
	Feature string
	// or
	Traffic TrafficDirection
}

ControlPoint identifies control point within a service that the rule or policy should apply to

ControlPoint is either a library feature name or one of ingress / egress traffic control point.

func ControlPointFromProto

func ControlPointFromProto(controlPoint *selectorv1.ControlPoint) ControlPoint

ControlPointFromProto creates a ControlPoint from "raw" proto-based ControlPoint

The controlPoint is assumed to be already validated and nonnil.

func (*ControlPoint) String

func (p *ControlPoint) String() string

String returns a string representation of either a library feature name or a traffic direction.

type ControlPointID

type ControlPointID struct {
	ServiceID    services.ServiceID
	ControlPoint ControlPoint
}

ControlPointID uniquely identifies the control point within a cluster – so it's a ServiceID and ControlPoint combined

Control Point.

func ControlPointIDFromProto

func ControlPointIDFromProto(selector *selectorv1.Selector) ControlPointID

ControlPointIDFromProto extracts a ControlPointID from proto-based selector (ignoring LabelMatcher)

Selector is assumed to be validated and non-nil.

func (ControlPointID) String

func (p ControlPointID) String() string

String returns a string representation of control point and service.

type LabelSources

type LabelSources struct {
	Flow    map[string]string
	Request *ext_authz.AttributeContext_Request
}

LabelSources describes all the sources of labels (flow and request).

type Labels

type Labels map[string]string

Labels is a flattened map of labels expected to be in canonical form to be used in LabelMatchers in Selectors.

Canonical form implies appropriate prefixes for different types of labels, see docs on policy/language/v1.Selector.

func NewLabels

func NewLabels(ls LabelSources) Labels

NewLabels maps all available labels into a flat namespace, as documented in policy/language/v1.Selector.

func (Labels) CombinedWith

func (l Labels) CombinedWith(newLabels LabelSources) Labels

CombinedWith combines existing labels with new labels from LabelSources.

The original labels map is unchanged. In case of duplicates, values from `newLabels` will be used.

func (Labels) ToPlainMap

func (l Labels) ToPlainMap() map[string]string

ToPlainMap extracts the underlying map of labels.

type Selector

type Selector struct {
	// Additionally, arbitrary label matcher can be used to match labels.
	// For policies this matcher can _also_ match flow labels.
	LabelMatcher mm.Expr
	// ServiceID and control point are required
	ControlPointID
}

Selector is a parsed/preprocessed version of policylangv1.Selector

refer to proto definition for docs.

func FromProto

func FromProto(selector *selectorv1.Selector) (Selector, error)

FromProto creates a Selector from a "raw" proto-based Selector

The selector is assumed to be already validated and non-nil.

type TrafficDirection

type TrafficDirection int

TrafficDirection indicates enumerated traffic direction.

const (
	// TrafficDirectionUndefined is a placeholder for undefined traffic direction.
	TrafficDirectionUndefined TrafficDirection = iota
	// Ingress is a traffic direction for inbound traffic.
	Ingress
	// Egress is a traffic direction for outbound traffic.
	Egress
)

func (TrafficDirection) String

func (d TrafficDirection) String() string

String returns a string representation of the traffic direction.

Jump to

Keyboard shortcuts

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