label

package
v0.0.0-...-1ba95a4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OpEq represents the Equals operator.
	OpEq = Op("eq")

	// OpNeq represents the Not Equal operator.
	OpNeq = Op("neq")

	// OpRegex represents the Regular Expression match operator.
	OpRegex = Op("regex")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key string

Key is the type for a label key.

func NewKey

func NewKey(str string) (key Key, err error)

NewKey creates a new Key from a string. It will return legal = false if the input contains illegal characters.

type Op

type Op string

Op represents the type of operator associated with a selector.

type Selector

type Selector struct {
	// Key is the key of the label that could potentially match the selector.
	Key Key `json:"label"`
	// Target is the argument to the operator. In the case of the
	// Eq operator, it is the exact string that needs to match the value.
	Target string `json:"target"`
	// Op is the operator.
	Op Op `json:"op"`
	// contains filtered or unexported fields
}

Selector is one selector on a label Set.

func (*Selector) Matches

func (s *Selector) Matches(labelSet Set) bool

Matches returns whether the given selector matches the labelSet. Calling Matches on invalid selectors results in undefined behavior. Refer to Validate().

func (*Selector) Validate

func (s *Selector) Validate() error

Validate returns whether the selector is valid. Calling Matches on invalid selectors results in undefined behavior.

type Set

type Set map[Key]Value

Set is a short name for map[Key]Value. Note that it is not thread-safe.

func NewSet

func NewSet() Set

NewSet returns a new Set.

func NewSetFromMap

func NewSetFromMap(input map[string]string) (Set, error)

NewSetFromMap tries to create a Set from an input of type map[string]string. It is used to verify user input and create a Set.

func (Set) Add

func (s Set) Add(key Key, value Value) (success bool)

Add adds a key-value pair to the Set. Duplicates are not allowed.

func (Set) Get

func (s Set) Get(key Key) (value Value, exists bool)

Get gets the value of a key from the Set.

func (Set) ToMap

func (s Set) ToMap() map[string]string

ToMap converts a Set to a plain map that can be used to produce a protobuf message.

type Value

type Value string

Value is the type for a label value.

func NewValue

func NewValue(str string) (value Value, err error)

NewValue creates a new Value from a string. It will return legal = false if the input contains illegal characters.

Jump to

Keyboard shortcuts

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