labelselector

package module
v0.0.0-...-7103996 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: MIT Imports: 6 Imported by: 0

README

labelselector

This package provides a parser for k8s label selectors.

It parses selectors like foo=bar or even foo, !bar, baz in (a, b, c), foo < 23.

Test coverage is at 100%!

Documentation

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 is a set of label requirements

func Parse

func Parse(input io.Reader) (LabelSelector, error)

Parse parses a label selector expression

func ParseString

func ParseString(str string) (LabelSelector, error)

ParseString parses a label selector expression from a string

type Lexer

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

func NewLexer

func NewLexer(r io.Reader) *Lexer

NewLexer returns a new instance of Lexer.

func (*Lexer) Next

func (s *Lexer) Next() (tok Token, lit string)

Next returns the next token and literal value.

type Operation

type Operation string
const (
	OperationIn               Operation = "in"
	OperationNotIn            Operation = "notIn"
	OperationExists           Operation = "exists"
	OperationEquals           Operation = "equals"
	OperationNotExists        Operation = "notExist"
	OperationNotEquals        Operation = "notEquals"
	OperationLowerThan        Operation = "lowerThan"
	OperationGreaterThan      Operation = "greaterThan"
	OperationLowerThanEqual   Operation = "lowerThanEqual"
	OperationGreaterThanEqual Operation = "greaterThanEqual"
)

type Parser

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

Parser is capable of parsing a label selector expression

func NewParser

func NewParser(input io.Reader) *Parser

NewParser creates a new parser instance

func (*Parser) Parse

func (p *Parser) Parse() (LabelSelector, error)

Parse actually parses the input and returns the resulting LabelSelector

type Requirement

type Requirement struct {
	Key       string
	Value     string
	Values    []string
	Operation Operation
}

type Token

type Token int

Token represents a lexical token.

const (
	ILLEGAL            Token = iota
	EOF                      // end of file
	WS                       // whitespace
	IDENT                    // identifier
	COMMA                    // ,
	EXCLAMATION_MARK         // !
	IN                       // in
	NOT_IN                   // notin
	EQUAL                    // = or ==
	NOT_EQUAL                // !=
	OPENING_BRACKET          // (
	CLOSING_BRACKET          // )
	LOWER_THAN               // <
	LOWER_THAN_EQUAL         // <=
	GREATER_THAN             // >
	GREATER_THAN_EQUAL       // >=
)

Jump to

Keyboard shortcuts

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