Skip to content

Commit

Permalink
fix: concurrency issue when parsing expression (#312)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly authored Feb 20, 2024
1 parent 163ee1b commit acadce6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/engine/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import (
"github.com/jmespath-community/go-jmespath/pkg/parsing"
)

var (
variable = regexp.MustCompile(`{{(.*?)}}`)
parser = parsing.NewParser()
)
var variable = regexp.MustCompile(`{{(.*?)}}`)

func String(ctx context.Context, in string, value any, bindings binding.Bindings, opts ...Option) string {
groups := variable.FindAllStringSubmatch(in, -1)
Expand All @@ -37,6 +34,7 @@ func String(ctx context.Context, in string, value any, bindings binding.Bindings
func Execute(ctx context.Context, statement string, value any, bindings binding.Bindings, opts ...Option) (any, error) {
o := buildOptions(opts...)
vm := interpreter.NewInterpreter(nil, bindings)
parser := parsing.NewParser()
compiled, err := parser.Parse(statement)
if err != nil {
return nil, err
Expand Down

0 comments on commit acadce6

Please sign in to comment.