Documentation
¶
Index ¶
- func NewContext(root []*yaml.Node) *ctx
- type ArithmeticExpr
- type ArithmeticOp
- type BooleanAndExpr
- type BooleanOrExpr
- type Comparator
- type CompareExpr
- type ConcatExpr
- type EqualityExpr
- type Expr
- type FieldExpr
- type FilterExpr
- type FuncExpr
- type InExpr
- type IndexExpr
- type MatchExpr
- type NegationExpr
- type PrefixMinusExpr
- type PrefixPlusExpr
- type RecursiveDescentExpr
- type RootExpr
- type ScriptExpr
- type SequenceExpr
- type Slice
- type SliceExpr
- type SubsetOfExpr
- type ValueExpr
- type WildcardExpr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶
func NewContext(root []*yaml.Node) *ctx
NewContext creates a new context with the given root node.
Types ¶
type ArithmeticExpr ¶
type ArithmeticExpr struct {
Left, Right Expr
Operation ArithmeticOp
}
ArithmeticExpr is a representation of the various arithmetic operations in the YAMLPath grammar, such as '-', '/', '*', and '%'. The only operator not included here is addition, since this is handled by the concat expression.
These operations are only able to operate on numeric values, and will error for all other types.
func (*ArithmeticExpr) Eval ¶
func (e *ArithmeticExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
Eval evaluates the arithmetic expression against the given context.
type ArithmeticOp ¶
ArithmeticOp is an arithmetic operation that takes two decimal.Decimal values.
var ( // Subtraction is the arithmetic subtraction operation for decimal objects. Subtraction ArithmeticOp = func(lhs, rhs decimal.Decimal) decimal.Decimal { return lhs.Sub(rhs) } // Multiplication is the arithmetic multiplication operation for decimal objects. Multiplication ArithmeticOp = func(lhs, rhs decimal.Decimal) decimal.Decimal { return lhs.Mul(rhs) } // Division is the arithmetic division operation for decimal objects. Division ArithmeticOp = func(lhs, rhs decimal.Decimal) decimal.Decimal { return lhs.Div(rhs) } // Modulus is the arithmetic modulus operation for decimal objects. Modulus ArithmeticOp = func(lhs, rhs decimal.Decimal) decimal.Decimal { return lhs.Mod(rhs) } )
type BooleanAndExpr ¶
type BooleanAndExpr struct {
Left, Right Expr
}
BooleanAndExpr represents a boolean AND expression.
func (*BooleanAndExpr) Eval ¶
func (e *BooleanAndExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
Eval evaluates the boolean AND expression against the given context.
type BooleanOrExpr ¶
type BooleanOrExpr struct {
Left, Right Expr
}
BooleanOrExpr represents a boolean OR expression.
func (*BooleanOrExpr) Eval ¶
func (e *BooleanOrExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
Eval evaluates the boolean OR expression against the given context.
type Comparator ¶
Comparator is a comparator function that represents a comparison operator.
var ( // CompareLess represents the '<' operator CompareLess Comparator = func(i int) bool { return i < 0 } // CompareGreater represents the '>' operator CompareGreater Comparator = func(i int) bool { return i > 0 } // CompareLessEqual represents the '<=' operator CompareLessEqual Comparator = func(i int) bool { return i <= 0 } // CompareGreaterEqual represents the '>=' operator CompareGreaterEqual Comparator = func(i int) bool { return i >= 0 } )
type CompareExpr ¶
type CompareExpr struct {
Left, Right Expr
Compare Comparator
}
CompareExpr is a representation of the various comparison operators for YAMLPath ('<=', '<', '>', '>='). Which operator is used here depends solely on the Compare field, which may be one of the Comparator definitions.
func (*CompareExpr) Eval ¶
func (e *CompareExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
Eval evaluates the comparison expression against the given nodes.
type ConcatExpr ¶
type ConcatExpr struct {
Left, Right Expr
}
ConcatExpr represents an expression that concatenates two expressions together using the '+' operator.
For strings, this produces a true concatenation of the strings. For integers, this is the addition operator. If either side of the operator is not compatible, this will return an error.
func (*ConcatExpr) Eval ¶
func (e *ConcatExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
type EqualityExpr ¶
type EqualityExpr struct {
Left, Right Expr
}
EqualityExpr is a representation of the '==' operator in the YAMLPath grammar. This enables comparison across both left and right sub-expressions.
func (*EqualityExpr) Eval ¶
func (e *EqualityExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
Eval evaluates the equality expression against the given nodes.
type Expr ¶
type Expr interface { // Eval evaluates the expression against the given context. Eval(ctx invocation.Context) ([]*yaml.Node, error) }
Expr represents an expression that can be evaluated against a YAML node.
type FieldExpr ¶
type FieldExpr struct {
Fields []string
}
FieldExpr extracts the fields from the nodes that match the named fields.
type FilterExpr ¶
type FilterExpr struct {
Expr Expr
}
FilterExpr is a representation of the filter operator `[?(...)]` in YAMLPath.
func (*FilterExpr) Eval ¶
func (f *FilterExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
Eval evaluates the filter expression against the provided nodes.
type FuncExpr ¶
type FuncExpr struct { Parameters []invocation.Parameter Func invocation.Func }
FuncExpr represents an expression that is implemented by a function that takes a context and returns a list of nodes.
type InExpr ¶
type InExpr struct {
Left, Right Expr
}
InExpr checks for the presence of a single value in a collection of values.
type IndexExpr ¶
type IndexExpr struct {
Indices []int64
}
IndexExpr is a representation of the indexing operator `[...]` in YAMLPath for numeric indexing of sequences.
This implements both union-indexing, which allows multiple selection, as well as just individual indexing. If an index is out-of-bounds, it is not selected -- no error is returned.
Negative indices allow selecting from the reverse side.
type NegationExpr ¶
type NegationExpr struct {
Expr Expr
}
NegationExpr is a representation of the '!' operator in YAMLPath expressions. It negates the result of the sub-expression.
func (*NegationExpr) Eval ¶
func (e *NegationExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
Eval evaluates the '!' operator against the provided nodes.
type PrefixMinusExpr ¶
type PrefixMinusExpr struct {
Expr Expr
}
func (*PrefixMinusExpr) Eval ¶
func (e *PrefixMinusExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
type PrefixPlusExpr ¶
type PrefixPlusExpr struct {
Expr Expr
}
PrefixPlusExpr is a representation of the unary '+' operator in YAMLPath.
This is effectively an identity expression that will only return the value back to the caller -- with the one exception that it will only operate on numeric values.
func (*PrefixPlusExpr) Eval ¶
func (e *PrefixPlusExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
Eval evaluates the unary '+' operator against the provided nodes.
type RecursiveDescentExpr ¶
type RecursiveDescentExpr struct{}
RecursiveDescentExpr is a representation of the recursive descent operator in YAMLPath expressions.
func (*RecursiveDescentExpr) Eval ¶
func (r *RecursiveDescentExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
Eval evaluates the recursive descent operator against the provided nodes.
type RootExpr ¶
type RootExpr struct {
Root string
}
RootExpr represents a root expression, either '$' or '@' in the path.
type ScriptExpr ¶
type ScriptExpr struct {
Expr Expr
}
ScriptExpr represents a script expression that can be used to create computed fields in a YAMLPath.
func (*ScriptExpr) Eval ¶
func (e *ScriptExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
Eval evaluates the script expression by evaluating the expression and using the result as a key to extract a value from the input nodes.
type SequenceExpr ¶
type SequenceExpr []Expr
SequenceExpr is a representation of a sequence of expressions in YAMLPath.
Almost every path is composed of sequence expressions that build up the path. For example, the path `$.foo.bar` is composed of three sequence expressions: `$`, `.foo`, and `.bar`.
func (*SequenceExpr) Append ¶
func (s *SequenceExpr) Append(expr Expr)
Append appends an expression to the sequence.
func (SequenceExpr) Eval ¶
func (s SequenceExpr) Eval(ctx invocation.Context) (nodes []*yaml.Node, err error)
Eval evaluates the sequence of expressions.
type Slice ¶
type Slice struct {
Start, End, Step int
}
Slice represents a slice expression in the form of `start[:end[:step]]` from the JSONPath specification.
func ParseSlice ¶
ParseSlice parses a slice expression from a string in the form of `start[:end[:step]]`.
type SliceExpr ¶
type SliceExpr struct {
Slice *Slice
}
SliceExpr is a representation of the `[start:end:step]` slice expression in YAMLPath, which will select a range of elements from a sequence node. Any non-sequence node objects are filtered and ignored.
type SubsetOfExpr ¶
type SubsetOfExpr struct {
Left, Right Expr
}
SubsetOfExpr checks if the left-hand side is a subset of the right-hand side of the expression.
func (*SubsetOfExpr) Eval ¶
func (e *SubsetOfExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
Eval evaluates the subset-of expression by checking if the left-hand side is a subset of the right-hand side.
type ValueExpr ¶
type ValueExpr struct {
Nodes []*yaml.Node
}
ValueExpr is an expression that always returns the specified value. This is primarily used to return literals that are specified in the path.
type WildcardExpr ¶
type WildcardExpr struct{}
WildcardExpr is a representation of the `.*` and `[*]` expressions in YAMLPath, which will select all fields or sequence elements from the current node.
func (*WildcardExpr) Eval ¶
func (*WildcardExpr) Eval(ctx invocation.Context) ([]*yaml.Node, error)
Eval evaluates the wildcard expression against the provided nodes.
Source Files
¶
- arithmetic_expr.go
- boolean_and_expr.go
- boolean_or_expr.go
- compare_expr.go
- concat_expr.go
- context.go
- equality_expr.go
- expr.go
- field_expr.go
- filter_expr.go
- func_expr.go
- in_expr.go
- index_expr.go
- match_expr.go
- negation_expr.go
- prefix_minus_expr.go
- prefix_plus_expr.go
- recursive_descent_expr.go
- root_expr.go
- script_expr.go
- sequence_expr.go
- slice.go
- slice_expr.go
- subsetof_expr.go
- value_expr.go
- wildcard_expr.go