eval

package
v1.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrType = fmt.Errorf("type error")

Functions

func Ignore added in v0.3.1

func Ignore() types.Value

func IsIgnore added in v0.3.1

func IsIgnore(v types.Value) bool

func IsVariable added in v0.3.1

func IsVariable(v types.Value) bool

func PartialError added in v1.2.6

func PartialError(err error) ast.IsNode

PartialError returns a node that represents a partial error.

func PartialPolicy added in v0.3.1

func PartialPolicy(env Env, p *ast.Policy) (policy *ast.Policy, keep bool)

PartialPolicy returns a partially evaluated version of the policy and a boolean indicating if the policy should be kept. (Policies that are determined to evaluate to false are not kept.)

func PolicyToNode added in v1.2.6

func PolicyToNode(p *ast.Policy) ast.Node

func ToPartialError added in v1.2.6

func ToPartialError(n ast.IsNode) (error, bool)

ToPartialError returns the error if the node is a partial error.

func ToVariable added in v0.3.1

func ToVariable(ent types.EntityUID) (types.String, bool)

func TypeName

func TypeName(v types.Value) string

func ValueToBool

func ValueToBool(v types.Value) (types.Boolean, error)

func ValueToDatetime added in v0.3.2

func ValueToDatetime(v types.Value) (types.Datetime, error)

func ValueToDecimal

func ValueToDecimal(v types.Value) (types.Decimal, error)

func ValueToDuration added in v0.3.2

func ValueToDuration(v types.Value) (types.Duration, error)

func ValueToEntity

func ValueToEntity(v types.Value) (types.EntityUID, error)

func ValueToIP

func ValueToIP(v types.Value) (types.IPAddr, error)

func ValueToLong

func ValueToLong(v types.Value) (types.Long, error)

func ValueToRecord

func ValueToRecord(v types.Value) (types.Record, error)

func ValueToSet

func ValueToSet(v types.Value) (types.Set, error)

func ValueToString

func ValueToString(v types.Value) (types.String, error)

func Variable added in v0.3.1

func Variable(v types.String) types.Value

Types

type BoolEvaler added in v0.3.1

type BoolEvaler struct {
	// contains filtered or unexported fields
}

func Compile

func Compile(p *ast.Policy) BoolEvaler

func (*BoolEvaler) Eval added in v0.3.1

func (e *BoolEvaler) Eval(env Env) (types.Boolean, error)

type ComparableValue added in v0.3.2

type ComparableValue interface {
	types.Value

	// LessThan returns true if the lhs is less than the rhs, and an
	// error if the rhs is not comparable to the lhs
	LessThan(types.Value) (bool, error)

	// LessThan returns true if the lhs is less than or equal to the
	// rhs, and an error if the rhs is not comparable to the lhs
	LessThanOrEqual(types.Value) (bool, error)
}

ComparableValue provides the interface that must be implemented to support operator overloading of <, <=, >, and >=

type Env added in v0.3.1

type Env struct {
	Entities                    types.EntityGetter
	Principal, Action, Resource types.Value
	Context                     types.Value
}

type Evaler

type Evaler interface {
	Eval(Env) (types.Value, error)
}

func ToEval added in v1.2.4

func ToEval(n ast.IsNode) Evaler

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL