Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make options public to allow custom interpreter usage #102

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/interpreter/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ func NewInterpreter(data interface{}, bindings binding.Bindings) Interpreter {
// It will produce the result of applying the JMESPath expression associated
// with the ASTNode to the input data "value".
func (intr *treeInterpreter) Execute(node parsing.ASTNode, value interface{}, opts ...Option) (interface{}, error) {
var o options
var o Options
for _, opt := range opts {
if opt != nil {
o = opt(o)
}
}
functionCaller := o.functionCaller
functionCaller := o.FunctionCaller
if functionCaller == nil {
functionCaller = DefaultFunctionCaller
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/interpreter/option.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package interpreter

type Option func(options) options
type Option func(Options) Options

type options struct {
functionCaller FunctionCaller
type Options struct {
FunctionCaller FunctionCaller
}

func WithFunctionCaller(functionCaller FunctionCaller) Option {
return func(o options) options {
o.functionCaller = functionCaller
return func(o Options) Options {
o.FunctionCaller = functionCaller
return o
}
}