Documentation
¶
Index ¶
- Variables
- type ActiveRuleset
- type Classifier
- func (c *Classifier) ActiveRules() []ReportedRule
- func (c *Classifier) AddRules(ctx context.Context, name string, classifier *classificationv1.Classifier) (ActiveRuleset, error)
- func (c *Classifier) Classify(ctx context.Context, svcs []services.ServiceID, ...) (FlowLabels, error)
- func (c *Classifier) GetClassifierID() iface.ClassifierID
- func (c *Classifier) GetSelector() *selectorv1.Selector
- type CompiledRuleset
- type FlowLabelValue
- type FlowLabels
- type LabelFlags
- type ProvideClassifierIn
- type ReportedRule
Constants ¶
This section is empty.
Variables ¶
var BadExtractor = extractors.BadExtractor
BadExtractor is an error occurring when extractor is invalid.
var BadLabelName = badLabelName{}
BadLabelName is an error occurring when label name is invalid.
var BadRego = badRego{}
BadRego is an error occurring when rego compilation fails.
var BadSelector = badSelector{}
BadSelector is an error occurring when selector is invalid.
var Module fx.Option = fx.Options( fx.Provide( fx.Annotated{ Target: setupEtcdClassifierWatcher, Name: "classifier", }, fx.Annotated{ Target: ProvideEmptyClassifier, Name: "empty", }, ProvideClassifier, ), )
Module is a default set of components to enable flow classification
Note: this module provides just a Classifier datastructure, with no API endpoint. Example API endpoint to the classifier is pkg/envoy.
Functions ¶
This section is empty.
Types ¶
type ActiveRuleset ¶
type ActiveRuleset struct {
// contains filtered or unexported fields
}
ActiveRuleset represents one of currently active set of rules.
func (ActiveRuleset) Drop ¶
func (rs ActiveRuleset) Drop()
Drop retracts all the rules belonging to a ruleset.
type Classifier ¶
type Classifier struct {
// contains filtered or unexported fields
}
Classifier receives classification policies and provides Classify method.
func ProvideClassifier ¶
func ProvideClassifier(in ProvideClassifierIn) *Classifier
ProvideClassifier provides a classifier that loads the rules from config file.
func ProvideEmptyClassifier ¶
func ProvideEmptyClassifier() *Classifier
ProvideEmptyClassifier provides a classifier that is empty
The classifier could be populated by calling UpdateRules.
func (*Classifier) ActiveRules ¶
func (c *Classifier) ActiveRules() []ReportedRule
ActiveRules returns a slice of uncompiled Rules which are currently active.
func (*Classifier) AddRules ¶
func (c *Classifier) AddRules( ctx context.Context, name string, classifier *classificationv1.Classifier, ) (ActiveRuleset, error)
AddRules compiles a ruleset and adds it to the active rules
The name will be used for reporting ¶
To retract the rules, call Classifier.Drop.
func (*Classifier) Classify ¶
func (c *Classifier) Classify( ctx context.Context, svcs []services.ServiceID, labelsForMatching selectors.Labels, direction selectors.TrafficDirection, input ast.Value, ) (FlowLabels, error)
Classify takes rego input, performs classification, and returns a map of flow labels. LabelsForMatching are additional labels to use for selector matching.
func (*Classifier) GetClassifierID ¶ added in v0.1.2
func (c *Classifier) GetClassifierID() iface.ClassifierID
GetClassifierID returns ClassifierID object that should uniquely identify classifier.
func (*Classifier) GetSelector ¶ added in v0.1.2
func (c *Classifier) GetSelector() *selectorv1.Selector
GetSelector returns the selector.
type CompiledRuleset ¶
type CompiledRuleset struct { ControlPointID selectors.ControlPointID Labelers []labelerWithSelector ReportedRules []ReportedRule }
CompiledRuleset is compiled form of Classifier proto.
func CompileRuleset ¶
func CompileRuleset(ctx context.Context, name string, classifier *classificationv1.Classifier) (CompiledRuleset, error)
CompileRuleset parses ruleset's selector and compiles its rules.
type FlowLabelValue ¶
type FlowLabelValue struct { Value string Flags LabelFlags }
FlowLabelValue is a value of a flow label with additional metadata.
type FlowLabels ¶
type FlowLabels map[string]FlowLabelValue
FlowLabels is a map from flow labels to their values.
func (FlowLabels) ToPlainMap ¶
func (fl FlowLabels) ToPlainMap() map[string]string
ToPlainMap returns flow labels as normal map[string]string.
type LabelFlags ¶
type LabelFlags struct { // Should the created label be applied to the whole flow (propagated in baggage) Propagate bool // Should the created flow label be hidden from telemetry Hidden bool }
LabelFlags are flags for a flow label.
type ProvideClassifierIn ¶
type ProvideClassifierIn struct { fx.In Classifier *Classifier `name:"empty"` Watcher notifiers.Watcher `name:"classifier"` Lifecycle fx.Lifecycle Registry status.Registry Engine iface.Engine }
ProvideClassifierIn holds parameters for ProvideClassifier.
type ReportedRule ¶
type ReportedRule struct { Selector *selectorv1.Selector Rule *classificationv1.Rule RulesetName string LabelName string }
ReportedRule is a rule along with its selector and label name.