Skip to content

Commit

Permalink
Return result of policy evaluation as is (don't cast)
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Feb 29, 2024
1 parent a032e5c commit 9e39508
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions act/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import (

"github.com/expr-lang/expr"
"github.com/expr-lang/expr/vm"
"github.com/spf13/cast"
)

type IPolicy interface {
MustCompile(opts ...expr.Option) error
Eval(ctx context.Context, input Input) (bool, error)
Eval(ctx context.Context, input Input) (any, error)
}

type Policy struct {
Expand All @@ -37,13 +36,13 @@ func (p *Policy) MustCompile(extraOpts ...expr.Option) error {
return nil
}

func (p *Policy) Eval(ctx context.Context, input Input) (bool, error) {
func (p *Policy) Eval(ctx context.Context, input Input) (any, error) {
output, err := expr.Run(p.prg, input)
if err != nil {
return false, err
}

return cast.ToBool(output), nil
return output, nil
}

func MustNewPolicy(
Expand Down

0 comments on commit 9e39508

Please sign in to comment.