filters

package
v0.15.0-rc.7 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: Apache-2.0 Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockSortedTagIterator

func NewMockSortedTagIterator(tags []byte) id.SortedTagIterator

NewMockSortedTagIterator creates a mock SortedTagIterator based on given ID.

Types

type Filter

type Filter interface {
	Clone() Filter
	// contains filtered or unexported methods
}

Filter matches a string against certain conditions.

func NewFilter

func NewFilter(pattern []byte) (Filter, error)

NewFilter supports startsWith, endsWith, contains and a single wildcard along with negation and glob matching support. NOTE: Currently only supports ASCII matching and has zero compatibility with UTF8 so you should make sure all matches are done against ASCII only.

func NewFilterFromFilterValue

func NewFilterFromFilterValue(fv FilterValue) (Filter, error)

NewFilterFromFilterValue creates a filter from the given filter value.

func NewMultiFilter

func NewMultiFilter(filters []Filter, op LogicalOp) Filter

NewMultiFilter returns a filter that chains multiple filters together using a LogicalOp.

func NewTagsFilter

func NewTagsFilter(
	filters TagFilterValueMap,
	op LogicalOp,
	opts TagsFilterOptions,
) (Filter, error)

NewTagsFilter creates a new tags filter.

type FilterValue

type FilterValue struct {
	Pattern string
	Negate  bool
}

FilterValue contains the filter pattern and a boolean flag indicating whether the filter should be negated.

type LogicalOp

type LogicalOp string

LogicalOp is a logical operator.

const (
	// Conjunction is logical AND.
	Conjunction LogicalOp = "&&"
	// Disjunction is logical OR.
	Disjunction LogicalOp = "||"
)

A list of supported logical operators.

type TagFilterValueMap

type TagFilterValueMap map[string]FilterValue

TagFilterValueMap is a map containing mappings from tag names to filter values.

func ParseTagFilterValueMap

func ParseTagFilterValueMap(str string) (TagFilterValueMap, error)

ParseTagFilterValueMap parses the input string and creates a tag filter value map.

func ValidateTagsFilter

func ValidateTagsFilter(str string) (TagFilterValueMap, error)

ValidateTagsFilter validates whether a given string is a valid tags filter, returning the filter values if the string is a valid tags filter expression, and the error otherwise.

type TagsFilterOptions

type TagsFilterOptions struct {
	// Name of the name tag.
	NameTagKey []byte

	// Function to extract name and tags from an id.
	NameAndTagsFn id.NameAndTagsFn

	// Function to create a new sorted tag iterator from id tags.
	SortedTagIteratorFn id.SortedTagIteratorFn
}

TagsFilterOptions provide a set of tag filter options.

Jump to

Keyboard shortcuts

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