Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyhb committed Jan 5, 2024
1 parent 2d0fd84 commit 60380f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 0 additions & 2 deletions caching_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (

var (
CacheTime = time.Hour

replace = []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t"}
)

// NewCachingParser returns a CELParser which lifts quoted literals out of the expression
Expand Down
14 changes: 14 additions & 0 deletions lift.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@ import (
"strings"
)

const (
// VarPrefix is the lifted variable name used when extracting idents from an
// expression.
VarPrefix = "vars."

Check failure on line 12 in lift.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

other declaration of VarPrefix (typecheck)

Check failure on line 12 in lift.go

View workflow job for this annotation

GitHub Actions / test-linux-race (ubuntu-latest)

other declaration of VarPrefix
)

var (
// replace is truly hack city. these are 20 variable names for values that are
// lifted out of expressions via liftLiterals.
replace = []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t"}
)

// LiftedArgs represents a set of variables that have been lifted from expressions and
// replaced with identifiers, eg `id == "foo"` becomes `id == vars.a`, with "foo" lifted
// as "vars.a".
type LiftedArgs interface {
// Get a lifted variable argument from the parsed expression.
Get(val string) (any, bool)
// Return all lifted variables as a map.
Map() map[string]any
}

Expand Down

0 comments on commit 60380f8

Please sign in to comment.