Documentation
¶
Overview ¶
Package invocation provides a mechanism for defining and invoking functions in a yamlpath expression.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownFunc = errors.New("unknown function")
ErrUnknownFunc is an error that is returned when a function is not found in the function table.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface { // Root returns the root node that started the full YAMLPath. Root() []*yaml.Node // Current returns the current node in the YAMLPath expression. // This is typically the node that should be operated on. Current() []*yaml.Node // NewContext returns a new context with the given node as the current node. NewContext([]*yaml.Node) Context // WithContext returns a new context with the given context. WithContext(context.Context) Context // GetContext retrieves the context from the invocation context. Context() context.Context }
Context is a representation of the current context of the yamlpath expression.
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry is a function entry in the function table.
type Func ¶
type Func interface { // Invoke invokes the function with the given context and arguments. Invoke(ctx Context, params ...Parameter) ([]*yaml.Node, error) // TestArity tests the arity of the function with the given number of // arguments. TestArity(n int) error }
Func is a representation of a function that can be used in a yamlpath expression.
type Parameter ¶
type Parameter interface { // GetArg retrieves the argument from the parameter. GetArg(Context) ([]*yaml.Node, error) }
Parameter is a representation of a parameter that can be used in a yamlpath expression.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is an invocation table that maps function names to function definitions.
func (*Table) Add ¶
Add adds a function to the table. By default, functions have an arity of zero -- meaning no arguments may be provided to them. To set the arity of the function, use the Entry.SetArity method on the returned Entry.
Directories
¶
Path | Synopsis |
---|---|
Package arity is a micro-package for providing the Arity type, which is used to identify whether the number of arguments being provided to an invocation is valid.
|
Package arity is a micro-package for providing the Arity type, which is used to identify whether the number of arguments being provided to an invocation is valid. |
Package invocationtest provides test-doubles for the invocation package
|
Package invocationtest provides test-doubles for the invocation package |