filter

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package filter implements common filters for the RDS (resource discovery service) providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filters

type Filters struct {
	RegexFilters map[string]*RegexFilter
	*LabelsFilter
	*FreshnessFilter
}

Filters encapsulates all types of filters. Its main purpose is to serve as a return type for ParseFilters.

func ParseFilters

func ParseFilters(filters []*pb.Filter, regexFilterKeys []string, freshnessFilterKey string) (*Filters, error)

ParseFilters parses filter protobufs into Filters struct. Filters are parsed based on the following criteria:

  • There can be multiple regex filters. Keys for these filters should be provided through the regexFilterKeys argument.
  • Labels filter keys always starts with the prefix "labels.".
  • There can be only one freshness filter, key for which should be provided through the freshnessFilterKey argument.

type FreshnessFilter

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

FreshnessFilter implements a filter that succeeds only if the given time is within a pre-defined duration.

func NewFreshnessFilter

func NewFreshnessFilter(dStr string) (*FreshnessFilter, error)

NewFreshnessFilter returns a new freshness filter.

func (*FreshnessFilter) Match

func (ff *FreshnessFilter) Match(t time.Time, l *logger.Logger) bool

Match returns true if the given time is within a pre-defined duration.

type LabelsFilter

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

LabelsFilter implements a filter on resource's labels.

func NewLabelsFilter

func NewLabelsFilter(labelsFilter map[string]string) (*LabelsFilter, error)

NewLabelsFilter builds LabelsFilter from a key:regexp map.

func (*LabelsFilter) Match

func (lf *LabelsFilter) Match(inputLabels map[string]string, l *logger.Logger) bool

Match returns true if provided string matches the regex of the filter. Otherwise, false is returned.

type RegexFilter

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

RegexFilter implements a regex based filter.

func NewRegexFilter

func NewRegexFilter(regexStr string) (*RegexFilter, error)

NewRegexFilter returns a new regex filter.

func (*RegexFilter) Match

func (rf *RegexFilter) Match(name string, l *logger.Logger) bool

Match returns true if provided string matches the regex of the filter. Otherwise, false is returned.

Jump to

Keyboard shortcuts

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