package
1.2.0
Repository: https://github.com/open-policy-agent/opa.git
Documentation: pkg.go.dev

# Packages

Deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended.
Package location defines locations in Rego source code.

# Functions

ArrayComprehensionTerm creates a new Term with an ArrayComprehension value.
ArrayTerm creates a new Term with an Array value.
As converts v into a Go native type referred to by x.
BooleanTerm creates a new Term with a Boolean value.
CallTerm returns a new Term with a Call value defined by terms.
CapabilitiesForThisVersion returns the capabilities of this version of OPA.
CheckPathConflicts returns a set of errors indicating paths that are in conflict with the result of the provided callable.
Compare returns an integer indicating whether two AST values are less than, equal to, or greater than each other.
CompileModules takes a set of Rego modules represented as strings and compiles them for evaluation.
CompileModulesWithOpt takes a set of Rego modules represented as strings and compiles them for evaluation.
ContainsClosures returns true if the Value v contains closures.
ContainsComprehensions returns true if the Value v contains comprehensions.
ContainsRefs returns true if the Value v contains refs.
Copy returns a deep copy of the AST node x.
EmptyRef returns a new, empty reference.
FloatNumberTerm creates a new Term with a floating point Number value.
InterfaceToValue converts a native Go value x to a Value.
InternedIntNumberTerm returns a term with the given integer value.
IntNumberTerm creates a new Term with an integer Number value.
IsComprehension returns true if the supplied value is a comprehension.
IsConstant returns true if the AST value is constant.
IsError returns true if err is an AST error with code.
IsKeyword returns true if s is a language keyword.
IsKeywordInRegoVersion returns true if s is a language keyword.
IsScalar returns true if the AST value is a scalar.
IsUnknownValueErr returns true if the err is an UnknownValueErr.
IsValidImportPath returns an error indicating if the import path is invalid.
Item is a helper for constructing an tuple containing two Terms representing a key/value pair in an Object.
JSON returns the JSON representation of v.
JSONWithOpt returns the JSON representation of v.
LoadCapabilitiesFile loads a JSON serialized capabilities structure from a file.
LoadCapabilitiesJSON loads a JSON serialized capabilities structure from the reader r.
LoadCapabilitiesVersion loads a JSON serialized capabilities structure from the specific version.
LoadCapabilitiesVersions loads all capabilities versions.
MustCompileModules compiles a set of Rego modules represented as strings.
MustCompileModulesWithOpts compiles a set of Rego modules represented as strings.
MustInterfaceToValue converts a native Go value x to a Value.
MustJSON returns the JSON representation of v.
MustParseBody returns a parsed body.
MustParseBodyWithOpts returns a parsed body.
MustParseExpr returns a parsed expression.
MustParseImports returns a slice of imports.
MustParseModule returns a parsed module.
MustParseModuleWithOpts returns a parsed module.
MustParsePackage returns a Package.
MustParseRef returns a parsed reference.
MustParseRule returns a parsed rule.
MustParseRuleWithOpts returns a parsed rule.
MustParseStatement returns exactly one statement.
MustParseStatements returns a slice of parsed statements.
MustParseTerm returns a parsed term.
NewArray creates an Array with the terms provided.
NewBeforeAfterVisitor returns a new BeforeAndAfterVisitor that will invoke the functions before and after AST nodes.
NewBody returns a new Body containing the given expressions.
NewBuiltinExpr creates a new Expr object with the supplied terms.
NewComment returns a new Comment object.
NewCompiler returns a new empty compiler.
NewError returns a new Error object.
NewExpr returns a new Expr object.
NewGenericTransformer returns a new GenericTransformer that will transform AST nodes using the function f.
NewGenericVisitor returns a new GenericVisitor that will invoke the function f on AST nodes.
NewGraph returns a new Graph based on modules.
NewGraphTraversal returns a Traversal for the dependency graph.
NewHead returns a new Head object.
NewIndexResult returns a new IndexResult object.
NewLocation returns a new Location object.
NewObject creates a new Object with t.
NewParser creates and initializes a Parser.
NewQueryContext returns a new QueryContext object.
NewRuleSet returns a new RuleSet containing the given rules.
NewRuleTree returns a new TreeNode that represents the root of the rule tree populated with the given rules.
NewSchemaSet returns an empty SchemaSet.
NewSet returns a new Set containing t.
NewTerm returns a new Term object.
NewValueMap returns a new ValueMap.
NewVarSet returns a new VarSet containing the specified variables.
NewVarVisitor returns a new VarVisitor object.
NullTerm creates a new Term with a Null value.
NumberTerm creates a new Term with a Number value.
ObjectComprehensionTerm creates a new Term with an ObjectComprehension value.
ObjectTerm creates a new Term with an Object value.
OutputVarsFromBody returns all variables which are the "output" for the given body.
OutputVarsFromExpr returns all variables which are the "output" for the given expression.
ParseBody returns exactly one body.
ParseBodyWithOpts returns exactly one body.
ParseCompleteDocRuleFromAssignmentExpr returns a rule if the expression can be interpreted as a complete document definition declared with the assignment operator.
ParseCompleteDocRuleFromEqExpr returns a rule if the expression can be interpreted as a complete document definition.
ParseExpr returns exactly one expression.
ParseImports returns a slice of Import objects.
ParseModule returns a parsed Module object.
ParseModuleWithOpts returns a parsed Module object, and has an additional input ParserOptions For details on Module objects and their fields, see policy.go.
ParsePackage returns exactly one Package.
ParsePartialObjectDocRuleFromEqExpr returns a rule if the expression can be interpreted as a partial object document definition.
ParsePartialSetDocRuleFromTerm returns a rule if the term can be interpreted as a partial set document definition.
ParseRef returns exactly one reference.
ParseRule returns exactly one rule.
ParseRuleFromBody returns a rule if the body can be interpreted as a rule definition.
ParseRuleFromCallEqExpr returns a rule if the term can be interpreted as a function definition (e.g., f(x) = y => f(x) = y { true }).
ParseRuleFromCallExpr returns a rule if the terms can be interpreted as a function returning true or some value (e.g., f(x) => f(x) = true { true }).
ParseRuleFromExpr returns a rule if the expression can be interpreted as a rule definition.
ParseRuleWithOpts returns exactly one rule.
ParseStatement returns exactly one statement.
ParseStatements is deprecated.
ParseStatementsWithOpts returns a slice of parsed statements.
ParseTerm returns exactly one term.
Pretty writes a pretty representation of the AST rooted at x to w.
PtrRef returns a new reference against the head for the pointer s.
RefHead returns a new Head object with the passed Ref.
RefTerm creates a new Term with a Ref value.
RegisterBuiltin adds a new built-in function to the registry.
SetComprehensionTerm creates a new Term with an SetComprehension value.
StringTerm creates a new Term with a String value.
Transform iterates the AST and calls the Transform function on the Transformer t for x before recursing.
TransformComprehensions calls the functio nf on all comprehensions under x.
TransformRefs calls the function f on all references under x.
TransformVars calls the function f on all vars under x.
TypeName returns a human readable name for the AST element type.
UIntNumberTerm creates a new Term with an unsigned integer Number value.
Unify returns a set of variables that will be unified when the equality expression defined by terms a and b is evaluated.
ValueFromReader returns an AST value from a JSON serialized value in the reader.
ValueToInterface returns the Go representation of an AST value.
VarHead creates a head object, initializes its Name, Location, and Options, and returns the new head.
VarTerm creates a new Term with a Variable value.
Walk iterates the AST by calling the Visit function on the Visitor v for x before recursing.
WalkBeforeAndAfter iterates the AST by calling the Visit function on the Visitor v for x before recursing.
WalkBodies calls the function f on all bodies under x.
WalkClosures calls the function f on all closures under x.
WalkExprs calls the function f on all expressions under x.
WalkNodes calls the function f on all nodes under x.
WalkRefs calls the function f on all references under x.
WalkRules calls the function f on all rules under x.
WalkTerms calls the function f on all terms under x.
WalkVars calls the function f on all vars under x.
WalkWiths calls the function f on all with modifiers under x.

# Constants

CompileErr indicates an unclassified compile error occurred.
CompileErrorLimitDefault is the default number errors a compiler will allow before exiting.
CompleteDoc represents a document that is completely defined by the rule.
EvalModeIR makes the compiler skip the stages for comprehension and rule indices.
EvalModeTopdown (default) instructs the compiler to build rule and comprehension indices used by topdown evaluation.
In the compiler, we used this to check that we're OK working with ref heads.
ParseErr indicates an unclassified parse error occurred.
PartialObjectDoc represents an object document that is partially defined by the rule.
PartialSetDoc represents a set document that is partially defined by the rule.
RecursionErr indicates recursion was found during compilation.
RegoV0 is the default, original Rego syntax.
RegoV0CompatV1 requires modules to comply with both the RegoV0 and RegoV1 syntax (as when 'rego.v1' is imported in a module).
RegoV1 is the Rego syntax enforced by OPA 1.0; e.g.: future.keywords part of default keyword set, and don't require imports; 'if' and 'contains' required in rule heads; (some) strict checks on by default.
SystemDocumentKey is the name of the top-level key that identifies the system document.
TypeErr indicates a type error was caught.
UnsafeVarErr indicates an unsafe variable was found during compilation.
WildcardPrefix is the special character that all wildcard variables are prefixed with when the statement they are contained in is parsed.

# Variables

All takes a list and returns true if all of the items are true.
Any takes a collection and returns true if any of the items is true.
Assign represents the assignment (":=") operator.
BuiltinMap provides a convenient mapping of built-in names to built-in definitions.
Builtins is the registry of built-in functions supported by OPA.
CastArray checks the underlying type of the input.
CastBoolean returns input if it is a boolean; if not returns error.
CastNull returns null if input is null; if not returns error.
CastObject returns the given object if it is null; throws an error otherwise.
CastSet checks the underlying type of the input.
CastString returns input if it is a string; if not returns error.
DefaultBuiltins is the registry of built-in functions supported in OPA by default.
DefaultRootDocument is the default root document.
DefaultRootRef is a reference to the root of the default document.
Equal represents the "==" comparison operator.
Equality represents the "=" operator.
FunctionArgRootDocument names the document containing function arguments.
FutureRootDocument names the document containing new, to-become-default, features.
GlobsMatch takes two strings regexp-style strings and evaluates to true if their intersection matches a non-empty set of non-empty strings.
GraphQLIsValid returns true if a GraphQL query is valid with a given schema, and returns false for all other inputs.
GraphQLParse returns a pair of AST objects from parsing/validation.
GraphQLParseAndVerify returns a boolean and a pair of AST object from parsing/validation.
GraphQLParseQuery parses the input GraphQL query and returns a JSON representation of its AST.
GraphQLParseSchema parses the input GraphQL schema and returns a JSON representation of its AST.
GraphQLSchemaIsValid returns true if the input is valid GraphQL schema, and returns false for all other inputs.
Marked non-deterministic because HTTP request results can be non-deterministic.
Deprecated: Builtins can now be directly annotated with the Nondeterministic property, and when set to true, will be ignored for partial evaluation.
InputRootDocument names the document containing query arguments.
InputRootRef is a reference to the root of the input document.
InternalPrint represents the internal implementation of the print() function.
JSONMatchSchema returns empty array if the document matches the JSON schema, and returns non-empty array with error objects otherwise.
JSONSchemaVerify returns empty string if the input is valid JSON schema and returns error string for all other inputs.
Marked non-deterministic because it relies on time internally.
Marked non-deterministic because it relies on RNG internally.
Marked non-deterministic because it relies on RNG internally.
Keywords contains strings that map to language keywords.
LessThan represents the "<" comparison operator.
Member represents the `in` (infix) operator.
MemberWithKey represents the `in` (infix) operator when used with two terms on the lhs, i.e., `k, v in obj`.
NetCIDROverlap has been replaced by the `net.cidr_contains` built-in.
Marked non-deterministic because DNS resolution results can be non-deterministic.
Marked non-deterministic because it relies on time directly.
Marked non-deterministic because of unpredictable config/environment-dependent results.
Or performs a union operation on sets.
Print is a special built-in function that writes zero or more operands to a message buffer.
RandIntn returns a random number 0 - n Marked non-deterministic because it relies on RNG internally.
RegexFind takes two strings and a number, the pattern, the value and number of match values to return, -1 means all match values.
RegexMatchDeprecated declares `re_match` which has been deprecated.
RegoMetadataRule returns the metadata for the active rule.
RegoRootDocument names the document containing new, to-become-default, features in a future versioned release.
ReservedVars is the set of names that refer to implicitly ground vars.
RootDocumentNames contains the names of top-level documents that can be referred to in modules and queries.
RootDocumentRefs contains the prefixes of top-level documents that all non-local references start with.
SafetyCheckVisitorParams defines the AST visitor parameters to use for collecting variables during the safety check.
SchemaRootDocument names the document containing external data schemas.
SchemaRootRef is a reference to the root of the schema document.
SetDiff has been replaced by the minus built-in.
TypeNameBuiltin returns the type of the input.
UUIDRFC4122 returns a version 4 UUID string.
Wildcard represents the wildcard variable as defined in the language.
YAMLIsValid verifies the input string is a valid YAML document.

# Type aliases

Array represents an array as defined by the language.
ArrayComprehension represents an array comprehension as defined in the language.
BeforeAfterVisitor provides a utility to walk over AST nodes using closures.
BeforeAndAfterVisitor wraps Visitor to provide hooks for being called before and after the AST has been visited.
Boolean represents a boolean value defined by JSON.
Builtin represents a built-in function supported by OPA.
Call represents as function call in the language.
Capabilities defines a structure containing data that describes the capabilities or features supported by a particular version of OPA.
CompileOpts defines a set of options for the compiler.
Compiler contains the state of a compilation process.
CompilerEvalMode allows toggling certain stages that are only needed for certain modes, Concretely, only "topdown" mode will have the compiler build comprehension and rule indices.
CompilerStage defines the interface for stages in the compiler.
CompilerStageDefinition defines a compiler stage.
ComprehensionIndex specifies how the comprehension term can be indexed.
DocKind represents the collection of document types that can be produced by rules.
Error represents a single error caught during parsing, compiling, etc.
ErrorDetails defines the interface for detailed error messages.
Errors represents a series of errors encountered during parsing, compiling, etc.
GenericTransformer implements the Transformer interface to provide a utility to transform AST nodes using a closure.
GenericVisitor provides a utility to walk over AST nodes using a closure.
Graph represents the graph of dependencies between rules.
GraphTraversal is a Traversal that understands the dependency graph.
IndexResult contains the result of an index lookup.
JSONOpt defines parameters for AST to JSON conversion.
Location records a position in source code.
ModuleLoader defines the interface that callers can implement to enable lazy loading of modules during compilation.
ModuleTreeNode represents a node in the module tree.
Null represents the null value defined by JSON.
Number represents a numeric value as defined by JSON.
Object represents an object as defined by the language.
ObjectComprehension represents an object comprehension as defined in the language.
NOTE(philipc): The only way to get an ObjectKeyIterator should be from an Object.
Parser is used to parse Rego statements.
ParserErrorDetail holds additional details for parser errors.
ParserOptions defines the options for parsing Rego statements.
QueryCompiler defines the interface for compiling ad-hoc queries.
QueryCompilerStage defines the interface for stages in the query compiler.
QueryCompilerStageDefinition defines a QueryCompiler stage.
QueryContext contains contextual information for running an ad-hoc query.
QueryIterator defines the interface for querying AST documents with references.
Ref represents a reference as defined by the language.
RefErrInvalidDetail describes an undefined reference error where the referenced value does not support the reference operand (e.g., missing object key, invalid key type, etc.).
RefErrUnsupportedDetail describes an undefined reference error where the referenced value does not support dereferencing (e.g., scalars).
RegoVersion defines the Rego syntax requirements for a module.
Resolver defines the interface for resolving references to native Go values.
RuleIndex defines the interface for rule indices.
RuleSet represents a collection of rules that produce a virtual document.
RulesOptions defines the options for retrieving rules by Ref from the compiler.
SchemaSet holds a map from a path to a schema.
Set represents a set as defined by the language.
SetComprehension represents a set comprehension as defined in the language.
String represents a string value as defined by JSON.
Term is an argument to a function.
Transformer defines the interface for transforming AST elements.
TreeNode represents a node in the rule tree.
TypeEnv contains type info for static analysis such as type checking.
UnificationErrDetail describes a type mismatch error when two values are unified (e.g., x = [1,2,y]).
UnknownValueErr indicates a ValueResolver was unable to resolve a reference because the reference refers to an unknown value.
Value declares the common interface for all Term values.
ValueMap represents a key/value map between AST term values.
ValueResolver defines the interface for resolving references to AST values.
Var represents a variable as defined by the language.
VarSet represents a set of variables.
VarVisitor walks AST nodes under a given node and collects all encountered variables.
VarVisitorParams contains settings for a VarVisitor.
VersonIndex contains an index from built-in function name, language feature, and future rego keyword to version number.
Visitor defines the interface for iterating AST elements.
WasmABIVersion captures the Wasm ABI version.