Documentation ¶
Overview ¶
Package fields implements a simple field system, parsing and matching selectors with sets of fields.
Index ¶
- func EscapeValue(s string) string
- func UnescapeValue(s string) (string, error)
- type Fields
- type InvalidEscapeSequence
- type Requirement
- type Requirements
- type Selector
- func AndSelectors(selectors ...Selector) Selector
- func Everything() Selector
- func Nothing() Selector
- func OneTermEqualSelector(k, v string) Selector
- func OneTermNotEqualSelector(k, v string) Selector
- func ParseAndTransformSelector(selector string, fn TransformFunc) (Selector, error)
- func ParseSelector(selector string) (Selector, error)
- func ParseSelectorOrDie(s string) Selector
- func SelectorFromSet(ls Set) Selector
- type Set
- type TransformFunc
- type UnescapedRune
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapeValue ¶
EscapeValue escapes an arbitrary literal string for use as a fieldSelector value
Types ¶
type Fields ¶
type Fields interface { // Has returns whether the provided field exists. Has(field string) (exists bool) // Get returns the value for the provided field. Get(field string) (value string) }
Fields allows you to present fields independently from their storage.
type InvalidEscapeSequence ¶
type InvalidEscapeSequence struct {
// contains filtered or unexported fields
}
InvalidEscapeSequence indicates an error occurred unescaping a field selector
func (InvalidEscapeSequence) Error ¶
func (i InvalidEscapeSequence) Error() string
type Requirement ¶
Requirement contains a field, a value, and an operator that relates the field and value. This is currently for reading internal selection information of field selector.
type Selector ¶
type Selector interface { // Matches returns true if this selector matches the given set of fields. Matches(Fields) 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 field to be set, and if so returns the value it // requires. RequiresExactMatch(field string) (value string, found bool) // Transform returns a new copy of the selector after TransformFunc has been // applied to the entire selector, or an error if fn returns an error. // If for a given requirement both field and value are transformed to empty // string, the requirement is skipped. Transform(fn TransformFunc) (Selector, error) // Requirements converts this interface to Requirements to expose // more detailed selection information. Requirements() Requirements // String returns a human readable string that represents this selector. String() string // Make a deep copy of the selector. DeepCopySelector() Selector }
Selector represents a field selector.
func AndSelectors ¶
AndSelectors creates a selector that is the logical AND of all the given selectors
func OneTermEqualSelector ¶
OneTermEqualSelector returns an object that matches objects where one field/field equals one value. Cannot return an error.
func OneTermNotEqualSelector ¶
OneTermNotEqualSelector returns an object that matches objects where one field/field does not equal one value. Cannot return an error.
func ParseAndTransformSelector ¶
func ParseAndTransformSelector(selector string, fn TransformFunc) (Selector, error)
ParseAndTransformSelector parses the selector and runs them through the given TransformFunc.
func ParseSelector ¶
ParseSelector takes a string representing a selector and returns an object suitable for matching, or an error.
func ParseSelectorOrDie ¶
ParseSelectorOrDie takes a string representing a selector and returns an object suitable for matching, or panic when an error occur.
type Set ¶
Set is a map of field:value. It implements Fields.
func (Set) AsSelector ¶
AsSelector converts fields into a selectors.
func (Set) Get ¶
Get returns the value in the map for the provided field.
func (Set) Has ¶
Has returns whether the provided field exists in the map.
type TransformFunc ¶
TransformFunc transforms selectors.
type UnescapedRune ¶
type UnescapedRune struct {
// contains filtered or unexported fields
}
UnescapedRune indicates an error occurred unescaping a field selector
func (UnescapedRune) Error ¶
func (i UnescapedRune) Error() string