filter

package
v4.2.0+incompatible Latest Latest
Warning

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

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

Documentation

Overview

Package filter contains common filtering logic that can be used to filter datapoints or various resources within other agent components, such as monitors. Filter instances have a Matches function which takes an instance of the type that they filter and return whether that instance matches the filter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicStringFilter

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

BasicStringFilter will match if any one of the given strings is a match.

func NewBasicStringFilter

func NewBasicStringFilter(items []string) (*BasicStringFilter, error)

NewBasicStringFilter returns a filter that can match against the provided items.

func (*BasicStringFilter) Matches

func (f *BasicStringFilter) Matches(s string) bool

Matches returns true if any one of the strings in the filter matches the input s

type ExhaustiveStringFilter

type ExhaustiveStringFilter struct {
	*BasicStringFilter
}

ExhaustiveStringFilter matches input strings that are positively matched by one of the input filters AND are not excluded by any negated filters (they work kind of like how .gitignore patterns work), OR are exactly matched by a literal filter input (e.g. not a globbed or regex pattern). Order of the items does not matter.

func NewExhaustiveStringFilter

func NewExhaustiveStringFilter(items []string) (*ExhaustiveStringFilter, error)

NewExhaustiveStringFilter makes a new ExhaustiveStringFilter with the given items.

func (*ExhaustiveStringFilter) Matches

func (f *ExhaustiveStringFilter) Matches(s string) bool

Matches if s is positively matched by the filter items AND is not excluded by any, OR if it is postively matched by a non-glob/regex pattern exactly and is negated as well. See the unit tests for examples.

type StringFilter

type StringFilter interface {
	Matches(string) bool
}

StringFilter matches against simple strings

type StringMapFilter

type StringMapFilter interface {
	Matches(map[string]string) bool
}

StringMapFilter matches against the values of a map[string]string.

func NewStringMapFilter

func NewStringMapFilter(m map[string]string) (StringMapFilter, error)

NewStringMapFilter returns a filter that matches against the provided map. All key/value pairs must match the spec given in m for a map to be considered a match.

Jump to

Keyboard shortcuts

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