selector

package
v0.0.0-...-3b05df2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Match

type Match map[string]string

func (Match) Match

func (m Match) Match(data map[string]string) bool

type Operation

type Operation struct {
	Key      string   `json:"key" yaml:"key"`
	Operator Operator `json:"operator" yaml:"operator"`
	Values   []string `json:"values" yaml:"values"`
}

func (*Operation) Match

func (o *Operation) Match(data map[string]string) bool

func (*Operation) Validate

func (o *Operation) Validate() error

Validate Operation. If any of these rules is violated, an error is returned:

  1. The operator can only be In, NotIn, Equals, DoubleEquals, Gt, Lt, NotEquals, Exists, or DoesNotExist.
  2. If the operator is In or NotIn, the values set must be non-empty.
  3. If the operator is Equals, DoubleEquals, or NotEquals, the values set must contain one value.
  4. If the operator is Exists or DoesNotExist, the value set must be empty.
  5. If the operator is Gt or Lt, the values set must contain only one value, which will be interpreted as an integer.
  6. The key is invalid due to its length, or sequence of characters. See validateLabelKey for more details.

The empty string is a valid value in the input values set.

type Operator

type Operator string
const (
	DoesNotExist Operator = "!"
	Equals       Operator = "="
	In           Operator = "in"
	NotEquals    Operator = "!="
	NotIn        Operator = "notin"
	Exists       Operator = "exists"
	GreaterThan  Operator = "gt"
	LessThan     Operator = "lt"
)

type Selector

type Selector struct {
	Matches    Match       `json:"matches,omitempty" yaml:"matches,omitempty"`
	Operations []Operation `json:"operations,omitempty" yaml:"operations,omitempty"`
}

func (*Selector) Match

func (s *Selector) Match(data map[string]string) bool

func (*Selector) Validate

func (s *Selector) Validate() error

Jump to

Keyboard shortcuts

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