query

package
Version: v0.11.9 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package query is a wrapper for Kubernetes Labels Selector (KLS). Wrapping KLS allows us to expose a simpler struct to other packages in this project. The simpler struct is also more flexible as it is agnostic to KLS, meaning we can add another query language in the future and not have to modify other packages in this project that import this query package. Lastly, the simpler struct is easier to mock and test with.

Index

Constants

This section is empty.

Variables

View Source
var Debug = false

Functions

func IsInvalidLabelChar added in v0.11.0

func IsInvalidLabelChar(r rune) bool

IsInvalidLabelChar returns true if the character is invalid for a label.

func IsOp added in v0.11.0

func IsOp(r rune) bool

IsOp returns true if the rune is an operator character.

Types

type Predicate

type Predicate struct {
	Label    string
	Operator string
	Value    interface{}
}

Predicate represents a predicate in a Query.

type Query

type Query struct {
	Predicates []Predicate
}

Query is a list of predicates.

func Translate

func Translate(labelSelectors string) (Query, error)

Translate parses KLS and wraps it in Query struct. It returns a Query and an error if encountered while parsing KLS.

type Requirement added in v0.11.0

type Requirement struct {
	Label  string
	Op     string
	Values []string
	// contains filtered or unexported fields
}

A Requirement represents one predicate parsed from a selector. For example, selector "x=y,z" has two requirements: "x=y" and "z". Op is the literal operator, or "exists" (p) or "notexists" (!p).

func Parse added in v0.11.0

func Parse(selector string) ([]Requirement, error)

Parse parses a Kubernetes Label Selector sttring.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL