labels

package
v0.0.0-...-ac8ee45 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2014 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package labels implements a simple label system, parsing and matching selectors with sets of labels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LabelSelector

type LabelSelector struct {
	Requirements []Requirement
}

LabelSelector only not named 'Selector' due to name conflict until Selector is deprecated.

func (*LabelSelector) Matches

func (sg *LabelSelector) Matches(ls Labels) bool

type Labels

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

Labels allows you to present labels independently from their storage.

type Operator

type Operator int

Operator represents a key's relationship to a set of values in a Requirement. TODO: Should also represent key's existence.

const (
	IN Operator = iota + 1
	NOT_IN
)

type Requirement

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

func (*Requirement) Matches

func (r *Requirement) Matches(ls Labels) bool

type Selector

type Selector interface {
	// Matches returns true if this selector matches the given set of labels.
	Matches(Labels) bool

	// Empty returns true if this selector does not restrict the selection space.
	Empty() bool

	// RequiresExactMatch allows a caller to introspect whether a given selector
	// requires a single specific label to be set, and if so returns the value it
	// requires.
	// TODO: expand this to be more general
	RequiresExactMatch(label string) (value string, found bool)

	// String returns a human readable string that represents this selector.
	String() string
}

Selector represents a label selector.

func Everything

func Everything() Selector

Everything returns a selector that matches all labels.

func ParseSelector

func ParseSelector(selector string) (Selector, error)

ParseSelector takes a string representing a selector and returns an object suitable for matching, or an error.

func SelectorFromSet

func SelectorFromSet(ls Set) Selector

SelectorFromSet returns a Selector which will match exactly the given Set. A nil Set is considered equivalent to Everything().

type Set

type Set map[string]string

Set is a map of label:value. It implements Labels.

func (Set) AsSelector

func (ls Set) AsSelector() Selector

AsSelector converts labels into a selectors.

func (Set) Get

func (ls Set) Get(label string) string

Get returns the value in the map for the provided label.

func (Set) String

func (ls Set) String() string

String returns all labels listed as a human readable string. Conveniently, exactly the format that ParseSelector takes.

Jump to

Keyboard shortcuts

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