labels

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(s string, opts ...field.PathOption) (selector.Selector, error)

Parse takes a string representing a selector and returns a selector object, or an error. This parsing function differs from ParseSelector as they parse different selectors with different syntaxes. The input will cause an error if it does not follow this form:

<selector-syntax>         ::= <requirement> | <requirement> "," <selector-syntax>
<requirement>             ::= [!] KEY [ <set-based-restriction> | <exact-match-restriction> ]
<set-based-restriction>   ::= "" | <inclusion-exclusion> <value-set>
<inclusion-exclusion>     ::= <inclusion> | <exclusion>
<exclusion>               ::= "notin"
<inclusion>               ::= "in"
<value-set>               ::= "(" <values> ")"
<values>                  ::= VALUE | VALUE "," <values>
<exact-match-restriction> ::= ["="|"=="|"!="] VALUE

KEY is a sequence of one or more characters following [ DNS_SUBDOMAIN "/" ] DNS_LABEL. Max length is 63 characters. VALUE is a sequence of zero or more characters "([A-Za-z0-9_-\.])". Max length is 63 characters. Delimiter is white space: (' ', '\t') Example of valid syntax:

"x in (foo,,baz),y,z notin ()"

Note:

  1. Inclusion - " in " - denotes that the KEY exists and is equal to any of the VALUEs in its requirement
  2. Exclusion - " notin " - denotes that the KEY is not equal to any of the VALUEs in its requirement or does not exist
  3. The empty string is a valid VALUE
  4. A requirement with just a KEY - as in "y" above - denotes that the KEY exists and can be any VALUE.
  5. A requirement with just !KEY requires that the KEY not exist.

func ParseSelectorOrDie

func ParseSelectorOrDie(s string) selector.Selector

Parse takes a string representing a selector and returns a selector object, or panic when an error occur. This parsing function differs from ParseSelector as they parse different selectors with different syntaxes. The input will cause an error if it does not follow this form:

<selector-syntax>         ::= <requirement> | <requirement> "," <selector-syntax>
<requirement>             ::= [!] KEY [ <set-based-restriction> | <exact-match-restriction> ]
<set-based-restriction>   ::= "" | <inclusion-exclusion> <value-set>
<inclusion-exclusion>     ::= <inclusion> | <exclusion>
<exclusion>               ::= "notin"
<inclusion>               ::= "in"
<value-set>               ::= "(" <values> ")"
<values>                  ::= VALUE | VALUE "," <values>
<exact-match-restriction> ::= ["="|"=="|"!="] VALUE

KEY is a sequence of one or more characters following [ DNS_SUBDOMAIN "/" ] DNS_LABEL. Max length is 63 characters. VALUE is a sequence of zero or more characters "([A-Za-z0-9_-\.])". Max length is 63 characters. Delimiter is white space: (' ', '\t') Example of valid syntax:

"x in (foo,,baz),y,z notin ()"

Note:

  1. Inclusion - " in " - denotes that the KEY exists and is equal to any of the VALUEs in its requirement
  2. Exclusion - " notin " - denotes that the KEY is not equal to any of the VALUEs in its requirement or does not exist
  3. The empty string is a valid VALUE
  4. A requirement with just a KEY - as in "y" above - denotes that the KEY exists and can be any VALUE.
  5. A requirement with just !KEY requires that the KEY not exist.

func ParseToRequirements

func ParseToRequirements(selector string, opts ...field.PathOption) ([]selector.Requirement, error)

ParseToRequirements takes a string representing a selector and returns a list of requirements. This function is suitable for those callers that perform additional processing on selector requirements.

Types

This section is empty.

Jump to

Keyboard shortcuts

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