myopa

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: MIT Imports: 5 Imported by: 0

README

myopa

My OPA playground

Tests

Library tests.

$ go test -v -cover

Example policy tests.

$ opa test . -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine is an OPA engine

func New

func New(policyFile string, module []byte) *Engine

New reads a policy file and returns a new engine

func (*Engine) Compile

func (e *Engine) Compile(ctx context.Context, query string, input interface{}, unknowns ...string) (Result, error)

Compile compiles the query

type Expr

type Expr struct {
	// Operator is the operator
	Operator Operator
	Left     *Operand
	Right    *Operand
}

Expr is an expression

type Operand

type Operand struct {
	// T is the operand type
	T OperandType
	// V is the operand value
	V interface{}
}

Val is an expression value

type OperandType

type OperandType int

OperandType is a value type

const (
	OperandTypeConstant OperandType = iota + 1
	OperandTypeIndexField
)

List of operand types

func (OperandType) String

func (vt OperandType) String() string

type Operator

type Operator int
const (
	OperatorEq Operator = iota + 1
)

func (Operator) String

func (op Operator) String() string

type Result

type Result struct {
	Defined bool
	Exprs   []*Expr
}

Result is a compilation result

Jump to

Keyboard shortcuts

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