opa

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

type Policy struct {
	ID string `json:"id"`
	// Method http method to be matched
	Method string `json:"method"`
	// Path http path to be matched
	Path string `json:"path"`
	// Policy contains the actual Rego policy as a string.
	Policy string `json:"policy"`
	// Query holds a set of Queries to be evaluated against the policy.
	Query Queries `json:"Query"`
	// Result stores the results of the policy evaluation.
	Result rego.Vars `json:"-"`
}

Policy represents a policy object for OPA (Open Policy Agent) evaluation. It's designed to work with Rego, the language for writing policies and queries for OPA. For more information about OPA and Rego, visit: https://www.openpolicyagent.org/docs/latest/

func (*Policy) BoolResult

func (p *Policy) BoolResult(query Query) bool

BoolResult extracts a string result for a given Query.

func (*Policy) Eval

func (p *Policy) Eval(ctx context.Context, input interface{}) error

Eval evaluates the policy against a given input, using OPA.

func (*Policy) IntResult

func (p *Policy) IntResult(query Query) int

IntResult extracts a int result for a given Query.

func (*Policy) MapResult

func (p *Policy) MapResult(query Query) map[string]interface{}

MapResult extracts a map result for a given Query.

func (*Policy) StringResult

func (p *Policy) StringResult(query Query) string

StringResult extracts a string result for a given Query.

type Queries

type Queries []Query

func (Queries) Eval

func (q Queries) Eval() string

type Query

type Query string

Query represents a string that can be used as a Query in OPA

func (Query) Eval

func (q Query) Eval() string

Eval generates a rego Query string from the Query.

func (Query) Var

func (q Query) Var() string

Var converts a Query to a variable format usable in rego.

Jump to

Keyboard shortcuts

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