labels

package
v0.0.0-...-98ba599 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package labels provides storing, fetching and matching based on labels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AndMatcher

type AndMatcher struct {
	Matchers []Matcher
}

AndMatcher is a composite matcher that selects all labels that are selected by all matchers.

func And

func And(ms ...Matcher) AndMatcher

And returns a composite matcher that selects all labels that are selected by all matchers.

func (AndMatcher) Matches

func (s AndMatcher) Matches(labels Labels) bool

Matches returns true if the labels are selected by one of the matchers in the andMatchers.

type InMatcher

type InMatcher struct {
	Key    string
	Values []string
}

InMatcher matches all labels where the label keys equals the key, and (optionally) the value has to be in the set of accepted values.

func In

func In(key string, values ...string) InMatcher

In matches all labels where the label keys equals the key, and (optionally) the value has to be in the set of accepted values.

func (InMatcher) Matches

func (s InMatcher) Matches(labels Labels) bool

Matches returns true if the labels are selected by one of the matchers in the inMatches.

type Labels

type Labels interface {
	// Get returns the value for the provided label.
	Get(label string) (value string, exists bool)
}

Labels is the interface for fetching labels.

type Matcher

type Matcher interface {
	Matches(labels Labels) bool
}

Matcher is the interface for matching objects based on their labels.

type OrMatcher

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

OrMatcher is a composite matcher that selects all labels that are selected by one of the matchers.

func Or

func Or(ms ...Matcher) OrMatcher

Or returns a composite matcher that selects all labels that are selected by one of the matchers.

func (OrMatcher) Matches

func (s OrMatcher) Matches(labels Labels) bool

Matches returns true if the labels are selected by one of the matchers in the orMatchers.

type Set

type Set map[string]string

Set is a set of labels, in which a key can only occur once.

func (Set) Get

func (l Set) Get(label string) (value string, exists bool)

Get fetches a label based on the key. If the label exists the value will be returned.

If the set is nil, Get will simply return that the label does not exist either.

func (*Set) Set

func (l *Set) Set(label, value string)

Set stores a label with the associated value.

If the set is nil, a set will be created. If a label with the same name exists already in the set, it will be overwritten.

Jump to

Keyboard shortcuts

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