expression

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package expression provides utilities to evaluate expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToJSONStandard added in v0.2.0

func ToJSONStandard(v interface{}) (interface{}, error)

ToJSONStandard converts the given value to a value that used by gojq.

Types

type DurationGetter

type DurationGetter interface {
	// Get returns a duration value.
	Get(ctx context.Context, v interface{}, now time.Time) (time.Duration, bool)
}

DurationGetter is a interface that can be used to get a time.Duration value.

func NewDurationFrom

func NewDurationFrom(value *time.Duration, src *string) (DurationGetter, error)

NewDurationFrom returns a new DurationGetter.

type Query

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

Query is wrapper of gojq.Query.

func NewQuery

func NewQuery(src string) (*Query, error)

NewQuery returns a new Query.

func (*Query) Execute

func (q *Query) Execute(ctx context.Context, v interface{}) ([]interface{}, error)

Execute executes the query with the given value.

type Requirement

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

Requirement contains values, a key, and an operator that relates the key and values. The zero value of Requirement is invalid.

func NewRequirement

func NewRequirement(key string, op internalversion.SelectorOperator, vals []string) (*Requirement, error)

NewRequirement is the constructor for a Requirement.

func (*Requirement) Matches

func (r *Requirement) Matches(ctx context.Context, matchData interface{}) (bool, error)

Matches returns true if the Requirement matches the input Labels. There is a match in the following cases: - the operator is 'In' and the value is in the set of values - the operator is 'NotIn' and the value is not in the set of values - the operator is 'Exists' and the key is defined and has a non-empty value - the operator is 'DoesNotExist' and the key is either not defined or has an empty value

Jump to

Keyboard shortcuts

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