Documentation
¶
Index ¶
- Constants
- Variables
- func Exclude(from interface{}, filters ...Filter) interface{}
- func Include(from interface{}, filters ...Filter) interface{}
- func MatchFilter(labels Labels, filter Filter) bool
- type Chain
- func (c Chain) Excluding(f ...Filter) Chain
- func (c Chain) From(from interface{}) interface{}
- func (c Chain) FromErr(from interface{}) (interface{}, error)
- func (c Chain) Including(f ...Filter) Chain
- func (c Chain) String() string
- func (c Chain) Then() Chain
- func (c Chain) ToGet(min, max int) Chain
- func (c Chain) ToGetAtLeast(want int) Chain
- func (c Chain) ToGetExactly(want int) Chain
- type Filter
- type LabelFunc
- type LabelString
- type LabelValue
- type Labelled
- type Labels
- type MatchMapArgContainer
- type MatchMapArgs
- type MatchMapConfig
- type MatchMapConfigValue
- type MatchMapConfigValues
- type Operator
- type OperatorFactory
- type SimpleFilter
Constants ¶
View Source
const ( OperatorKey = "" OperatorEqual = "==" OperatorNotEqual = "!=" OperatorRegex = "?=" )
Variables ¶
View Source
var Operators = map[string]OperatorFactory{ "==": func(key, value string) (Operator, error) { return func(v string) bool { return value == v }, nil }, "!=": func(key, value string) (Operator, error) { return func(v string) bool { return value != v }, nil }, "?=": func(key, value string) (operator Operator, e error) { re, err := regexp.Compile(value) if err != nil { return nil, errors.Errorf("bad regex in %s?=%s: %s", key, value, err) } return func(value string) bool { return re.MatchString(value) }, nil }, }
Functions ¶
func MatchFilter ¶
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
func (Chain) From ¶
func (c Chain) From(from interface{}) interface{}
From returns the filtered set, or an empty value of the same type as from if an expectation failed.
func (Chain) FromErr ¶
FromErr returns the filtered set, or an error if all steps failed expectations.
func (Chain) ToGetAtLeast ¶
func (Chain) ToGetExactly ¶
type Filter ¶
func FilterFromOperator ¶
FilterFromOperator creates a new filter with the given operator.
func FilterMatchAll ¶
func FilterMatchAll() Filter
func Parse ¶
Parse returns a filter based on key, value, and operator Argument patterns: `"key"` - Will match if the key is found `"keyOPvalue"` - Where OP is one or more none-word characters, will check the value of key against the provided value using the operator `"key", "op", "value"` - Will check the value at key against the value using the operator
type LabelString ¶
type LabelString string
func (LabelString) Value ¶
func (l LabelString) Value() string
type LabelValue ¶
type LabelValue interface {
Value() string
}
type Labels ¶
type Labels map[string]LabelValue
func LabelsFromMap ¶
func (Labels) MarshalYAML ¶
func (*Labels) UnmarshalYAML ¶
type MatchMapArgContainer ¶
type MatchMapArgContainer interface { GetMatchMapArgs() MatchMapArgs WithMatchMapArgs(args MatchMapArgs) interface{} }
type MatchMapArgs ¶
func (MatchMapArgs) String ¶
func (e MatchMapArgs) String() string
type MatchMapConfig ¶
type MatchMapConfig map[string]MatchMapConfigValues
func (MatchMapConfig) Matches ¶
func (e MatchMapConfig) Matches(args MatchMapArgs) bool
type MatchMapConfigValue ¶
type MatchMapConfigValue string
func (MatchMapConfigValue) Matches ¶
func (m MatchMapConfigValue) Matches(arg string) bool
type MatchMapConfigValues ¶
type MatchMapConfigValues []MatchMapConfigValue
func MatchMapConfigValuesFromStrings ¶
func MatchMapConfigValuesFromStrings(ss []string) MatchMapConfigValues
type OperatorFactory ¶
type SimpleFilter ¶
func (SimpleFilter) IsMatch ¶
func (s SimpleFilter) IsMatch(l Labels) bool
func (SimpleFilter) String ¶
func (s SimpleFilter) String() string
Click to show internal directories.
Click to hide internal directories.