kvcondition

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 5 Imported by: 1

README

KV Condition

GoDoc Widget Build Status codecov Go Report Card

Simple query language to describe condition for label

  • equal rules:
    • value equal key="value"
    • value not equal key!="value"
    • value ends with key$="value"
    • value starts with key^="value"
    • value contains key*="value"
    • has key key
  • compose rules:
    • and &
    • or |
    • hoisting operator precedence ()

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SyntaxErrorMissingRightBracket = errors.New("kv condition missing right bracket")
	SyntaxErrorInvalidCondition    = errors.New("kv condition invalid condition")
)
View Source
var (
	UnknownOperator = errors.New("unknown operator")
)

Functions

This section is empty.

Types

type Condition

type Condition struct {
	Operator ConditionOperator
	Left     Node
	Right    Node
}

func And

func And(left Node, right Node) *Condition

func Or

func Or(left Node, right Node) *Condition

func (*Condition) String

func (c *Condition) String() string

type ConditionOperator

type ConditionOperator int
const (
	ConditionOperatorAND ConditionOperator = iota + 1
	ConditionOperatorOR
)

type KVCondition

type KVCondition struct {
	Node
}

openapi:strfmt kv-condition

func ParseKVCondition

func ParseKVCondition(r []byte) (*KVCondition, error)

func (KVCondition) IsZero

func (v KVCondition) IsZero() bool

func (KVCondition) MarshalText

func (v KVCondition) MarshalText() ([]byte, error)

func (*KVCondition) Range

func (v *KVCondition) Range(cb func(condition *Rule))

func (*KVCondition) UnmarshalText

func (v *KVCondition) UnmarshalText(data []byte) error

type Node

type Node interface {
	String() string
}

type Operator

type Operator int
const (
	OperatorExists Operator = iota
	OperatorEqual
	OperatorNotEqual
	OperatorContains
	OperatorStartsWith
	OperatorEndsWith
)

func ParseOperator

func ParseOperator(op string) (Operator, error)

func (Operator) Of

func (op Operator) Of(key string, value string) *Rule

func (Operator) String

func (op Operator) String() string

type Rule

type Rule struct {
	Operator Operator
	Key      []byte
	Value    []byte
}

func (*Rule) String

func (l *Rule) String() string

Jump to

Keyboard shortcuts

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