Movatterモバイル変換


[0]ホーム

URL:


ast

package
v1.13.1Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License:Apache-2.0Imports:6Imported by:757

Details

Repository

github.com/open-policy-agent/opa

Links

Documentation

Overview

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.For newer features and behaviours, such as defaulting to the Rego v1 syntax, use the corresponding components in thegithub.com/open-policy-agent/opa/v1 package instead.Seehttps://www.openpolicyagent.org/docs/latest/v0-compatibility/ for more information.

Index

Constants

View Source
const (// EvalModeTopdown (default) instructs the compiler to build rule// and comprehension indices used by topdown evaluation.EvalModeTopdown =v1.EvalModeTopdown// EvalModeIR makes the compiler skip the stages for comprehension// and rule indices.EvalModeIR =v1.EvalModeIR)
View Source
const (// ParseErr indicates an unclassified parse error occurred.ParseErr =v1.ParseErr// CompileErr indicates an unclassified compile error occurred.CompileErr =v1.CompileErr// TypeErr indicates a type error was caught.TypeErr =v1.TypeErr// UnsafeVarErr indicates an unsafe variable was found during compilation.UnsafeVarErr =v1.UnsafeVarErr// RecursionErr indicates recursion was found during compilation.RecursionErr =v1.RecursionErr)
View Source
const (RegoUndefined =v1.RegoUndefined// RegoV0 is the default, original Rego syntax.RegoV0 =v1.RegoV0// RegoV0CompatV1 requires modules to comply with both the RegoV0 and RegoV1 syntax (as when 'rego.v1' is imported in a module).// Shortly, RegoV1 compatibility is required, but 'rego.v1' or 'future.keywords' must also be imported.RegoV0CompatV1 =v1.RegoV0CompatV1// 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.RegoV1 =v1.RegoV1)
View Source
const (// CompleteDoc represents a document that is completely defined by the rule.CompleteDoc =v1.CompleteDoc// PartialSetDoc represents a set document that is partially defined by the rule.PartialSetDoc =v1.PartialSetDoc// PartialObjectDoc represents an object document that is partially defined by the rule.PartialObjectDoc =v1.PartialObjectDoc)
View Source
const (SingleValue =v1.SingleValueMultiValue  =v1.MultiValue)
View Source
const CompileErrorLimitDefault = 10

CompileErrorLimitDefault is the default number errors a compiler will allow beforeexiting.

View Source
const DefaultRegoVersion =RegoV0
View Source
const FeatureRefHeadStringPrefixes =v1.FeatureRefHeadStringPrefixes

In the compiler, we used this to check that we're OK working with ref heads.If this isn't present, we'll fail. This is to ensure that older versions ofOPA can work with policies that we're compiling -- if they don't know refheads, they wouldn't be able to parse them.

View Source
const FeatureRefHeads =v1.FeatureRefHeads
View Source
const FeatureRegoV1 =v1.FeatureRegoV1
View Source
const FeatureRegoV1Import =v1.FeatureRegoV1Import
View Source
const SystemDocumentKey =v1.SystemDocumentKey

SystemDocumentKey is the name of the top-level key that identifies the systemdocument.

View Source
const WildcardPrefix =v1.WildcardPrefix

WildcardPrefix is the special character that all wildcard variables areprefixed with when the statement they are contained in is parsed.

Variables

View Source
var AddDate =v1.AddDate

All takes a list and returns true if all of the itemsare true. A collection of length 0 returns true.

Any takes a collection and returns true if any of the itemsis true. A collection of length 0 returns false.

View Source
var AnyPrefixMatch =v1.AnyPrefixMatch
View Source
var AnySuffixMatch =v1.AnySuffixMatch
View Source
var ArrayConcat =v1.ArrayConcat
View Source
var ArrayReverse =v1.ArrayReverse
View Source
var ArraySlice =v1.ArraySlice
View Source
var Assign =v1.Assign

Assign represents the assignment (":=") operator.

View Source
var Base64Decode =v1.Base64Decode
View Source
var Base64Encode =v1.Base64Encode
View Source
var Base64IsValid =v1.Base64IsValid
View Source
var Base64UrlDecode =v1.Base64UrlDecode
View Source
var Base64UrlEncode =v1.Base64UrlEncode
View Source
var Base64UrlEncodeNoPad =v1.Base64UrlEncodeNoPad
View Source
var BitsAnd =v1.BitsAnd
View Source
var BitsNegate =v1.BitsNegate
View Source
var BitsOr =v1.BitsOr
View Source
var BitsShiftLeft =v1.BitsShiftLeft
View Source
var BitsShiftRight =v1.BitsShiftRight
View Source
var BitsXOr =v1.BitsXOr
View Source
var BuiltinMap =v1.BuiltinMap

BuiltinMap provides a convenient mapping of built-in names tobuilt-in definitions.

View Source
var Builtins =v1.Builtins

Builtins is the registry of built-in functions supported by OPA.Call RegisterBuiltin to add a new built-in.

View Source
var CastArray =v1.CastArray

CastArray checks the underlying type of the input. If it is array or set, an arraycontaining the values is returned. If it is not an array, an error is thrown.

View Source
var CastBoolean =v1.CastBoolean

CastBoolean returns input if it is a boolean; if not returns error.

View Source
var CastNull =v1.CastNull

CastNull returns null if input is null; if not returns error.

View Source
var CastObject =v1.CastObject

CastObject returns the given object if it is null; throws an error otherwise

View Source
var CastSet =v1.CastSet

CastSet checks the underlying type of the input.If it is a set, the set is returned.If it is an array, the array is returned in set form (all duplicates removed)If neither, an error is thrown

View Source
var CastString =v1.CastString

CastString returns input if it is a string; if not returns error.For formatting variables, see sprintf

View Source
var Clock =v1.Clock
View Source
var Concat =v1.Concat
View Source
var Contains =v1.Contains
View Source
var Count =v1.Count
View Source
var CryptoHmacEqual =v1.CryptoHmacEqual
View Source
var CryptoHmacMd5 =v1.CryptoHmacMd5
View Source
var CryptoHmacSha1 =v1.CryptoHmacSha1
View Source
var CryptoHmacSha256 =v1.CryptoHmacSha256
View Source
var CryptoHmacSha512 =v1.CryptoHmacSha512
View Source
var CryptoMd5 =v1.CryptoMd5
View Source
var CryptoParsePrivateKeys =v1.CryptoParsePrivateKeys
View Source
var CryptoSha1 =v1.CryptoSha1
View Source
var CryptoSha256 =v1.CryptoSha256
View Source
var CryptoX509ParseAndVerifyCertificates =v1.CryptoX509ParseAndVerifyCertificates
View Source
var CryptoX509ParseAndVerifyCertificatesWithOptions =v1.CryptoX509ParseAndVerifyCertificatesWithOptions
View Source
var CryptoX509ParseCertificateRequest =v1.CryptoX509ParseCertificateRequest
View Source
var CryptoX509ParseCertificates =v1.CryptoX509ParseCertificates
View Source
var CryptoX509ParseKeyPair =v1.CryptoX509ParseKeyPair
View Source
var CryptoX509ParseRSAPrivateKey =v1.CryptoX509ParseRSAPrivateKey
View Source
var DefaultBuiltins =v1.DefaultBuiltins

DefaultBuiltins is the registry of built-in functions supported in OPAby default. When adding a new built-in function to OPA, update thislist.

View Source
var DefaultRootDocument =v1.DefaultRootDocument

DefaultRootDocument is the default root document.

All package directives inside source files are implicitly prefixed with theDefaultRootDocument value.

View Source
var DefaultRootRef =v1.DefaultRootRef

DefaultRootRef is a reference to the root of the default document.

All refs to data in the policy engine's storage layer are prefixed with this ref.

View Source
var Divide =v1.Divide
View Source
var EndsWith =v1.EndsWith
View Source
var Equal =v1.Equal

Equal represents the "==" comparison operator.

View Source
var Equality =v1.Equality

Equality represents the "=" operator.

View Source
var Floor =v1.Floor
View Source
var Format =v1.Format
View Source
var FormatInt =v1.FormatInt
View Source
var FunctionArgRootDocument =v1.FunctionArgRootDocument

FunctionArgRootDocument names the document containing function arguments.It's only for internal usage, for referencing function arguments betweenthe index and topdown.

View Source
var FutureRootDocument =v1.FutureRootDocument

FutureRootDocument names the document containing new, to-become-default,features.

View Source
var GlobMatch =v1.GlobMatch
View Source
var GlobQuoteMeta =v1.GlobQuoteMeta
View Source
var GlobsMatch =v1.GlobsMatch

GlobsMatch takes two strings regexp-style strings and evaluates to true if theirintersection matches a non-empty set of non-empty strings.Examples:

  • "a.a." and ".b.b" -> true.
  • "[a-z]*" and [0-9]+" -> not true.
View Source
var GraphQLIsValid =v1.GraphQLIsValid

GraphQLIsValid returns true if a GraphQL query is valid with a givenschema, and returns false for all other inputs.

View Source
var GraphQLParse =v1.GraphQLParse

GraphQLParse returns a pair of AST objects from parsing/validation.

View Source
var GraphQLParseAndVerify =v1.GraphQLParseAndVerify

GraphQLParseAndVerify returns a boolean and a pair of AST object from parsing/validation.

View Source
var GraphQLParseQuery =v1.GraphQLParseQuery

GraphQLParseQuery parses the input GraphQL query and returns a JSONrepresentation of its AST.

View Source
var GraphQLParseSchema =v1.GraphQLParseSchema

GraphQLParseSchema parses the input GraphQL schema and returns a JSONrepresentation of its AST.

View Source
var GraphQLSchemaIsValid =v1.GraphQLSchemaIsValid

GraphQLSchemaIsValid returns true if the input is valid GraphQL schema,and returns false for all other inputs.

View Source
var GreaterThan =v1.GreaterThan
View Source
var GreaterThanEq =v1.GreaterThanEq
View Source
var HTTPSend =v1.HTTPSend

Marked non-deterministic because HTTP request results can be non-deterministic.

View Source
var HexDecode =v1.HexDecode
View Source
var HexEncode =v1.HexEncode
View Source
var IgnoreDuringPartialEval =v1.IgnoreDuringPartialEval

Deprecated: Builtins can now be directly annotated with theNondeterministic property, and when set to true, will be ignoredfor partial evaluation.

View Source
var IndexOf =v1.IndexOf
View Source
var IndexOfN =v1.IndexOfN
View Source
var InputRootDocument =v1.InputRootDocument

InputRootDocument names the document containing query arguments.

View Source
var InputRootRef =v1.InputRootRef

InputRootRef is a reference to the root of the input document.

All refs to query arguments are prefixed with this ref.

View Source
var InternalPrint =v1.InternalPrint

InternalPrint represents the internal implementation of the print() function.The compiler rewrites print() calls to refer to the internal implementation.

View Source
var Intersection =v1.Intersection
View Source
var IsArray =v1.IsArray
View Source
var IsBoolean =v1.IsBoolean
View Source
var IsNull =v1.IsNull
View Source
var IsNumber =v1.IsNumber
View Source
var IsObject =v1.IsObject
View Source
var IsSet =v1.IsSet
View Source
var IsString =v1.IsString
View Source
var JSONFilter =v1.JSONFilter
View Source
var JSONIsValid =v1.JSONIsValid
View Source
var JSONMarshal =v1.JSONMarshal
View Source
var JSONMarshalWithOptions =v1.JSONMarshalWithOptions
View Source
var JSONMatchSchema =v1.JSONMatchSchema

JSONMatchSchema returns empty array if the document matches the JSON schema,and returns non-empty array with error objects otherwise.

View Source
var JSONPatch =v1.JSONPatch
View Source
var JSONRemove =v1.JSONRemove
View Source
var JSONSchemaVerify =v1.JSONSchemaVerify

JSONSchemaVerify returns empty string if the input is valid JSON schemaand returns error string for all other inputs.

View Source
var JSONUnmarshal =v1.JSONUnmarshal
View Source
var JWTDecode =v1.JWTDecode
View Source
var JWTDecodeVerify =v1.JWTDecodeVerify

Marked non-deterministic because it relies on time internally.

View Source
var JWTEncodeSign =v1.JWTEncodeSign

Marked non-deterministic because it relies on RNG internally.

View Source
var JWTEncodeSignRaw =v1.JWTEncodeSignRaw

Marked non-deterministic because it relies on RNG internally.

View Source
var JWTVerifyES256 =v1.JWTVerifyES256
View Source
var JWTVerifyES384 =v1.JWTVerifyES384
View Source
var JWTVerifyES512 =v1.JWTVerifyES512
View Source
var JWTVerifyHS256 =v1.JWTVerifyHS256
View Source
var JWTVerifyHS384 =v1.JWTVerifyHS384
View Source
var JWTVerifyHS512 =v1.JWTVerifyHS512
View Source
var JWTVerifyPS256 =v1.JWTVerifyPS256
View Source
var JWTVerifyPS384 =v1.JWTVerifyPS384
View Source
var JWTVerifyPS512 =v1.JWTVerifyPS512
View Source
var JWTVerifyRS256 =v1.JWTVerifyRS256
View Source
var JWTVerifyRS384 =v1.JWTVerifyRS384
View Source
var JWTVerifyRS512 =v1.JWTVerifyRS512
View Source
var Keywords =v1.Keywords

Keywords contains strings that map to language keywords.

View Source
var KeywordsV0 =v1.KeywordsV0
View Source
var KeywordsV1 =v1.KeywordsV1
View Source
var LessThan =v1.LessThan

LessThan represents the "<" comparison operator.

View Source
var LessThanEq =v1.LessThanEq
View Source
var Lower =v1.Lower
View Source
var Member =v1.Member

Member represents the `in` (infix) operator.

View Source
var MemberWithKey =v1.MemberWithKey

MemberWithKey represents the `in` (infix) operator when usedwith two terms on the lhs, i.e., `k, v in obj`.

View Source
var Minus =v1.Minus
View Source
var Multiply =v1.Multiply
View Source
var NetCIDRContains =v1.NetCIDRContains
View Source
var NetCIDRContainsMatches =v1.NetCIDRContainsMatches
View Source
var NetCIDRExpand =v1.NetCIDRExpand
View Source
var NetCIDRIntersects =v1.NetCIDRIntersects
View Source
var NetCIDRIsValid =v1.NetCIDRIsValid
View Source
var NetCIDRMerge =v1.NetCIDRMerge
View Source
var NetCIDROverlap =v1.NetCIDROverlap

NetCIDROverlap has been replaced by the `net.cidr_contains` built-in.

View Source
var NetLookupIPAddr =v1.NetLookupIPAddr

Marked non-deterministic because DNS resolution results can be non-deterministic.

View Source
var NotEqual =v1.NotEqual
View Source
var NowNanos =v1.NowNanos

Marked non-deterministic because it relies on time directly.

View Source
var NumbersRange =v1.NumbersRange
View Source
var NumbersRangeStep =v1.NumbersRangeStep
View Source
var OPARuntime =v1.OPARuntime

Marked non-deterministic because of unpredictable config/environment-dependent results.

View Source
var ObjectFilter =v1.ObjectFilter
View Source
var ObjectGet =v1.ObjectGet
View Source
var ObjectKeys =v1.ObjectKeys
View Source
var ObjectRemove =v1.ObjectRemove
View Source
var ObjectSubset =v1.ObjectSubset
View Source
var ObjectUnion =v1.ObjectUnion
View Source
var ObjectUnionN =v1.ObjectUnionN

Or performs a union operation on sets.

View Source
var ParseDurationNanos =v1.ParseDurationNanos
View Source
var ParseNanos =v1.ParseNanos
View Source
var ParseRFC3339Nanos =v1.ParseRFC3339Nanos
View Source
var Print =v1.Print

Print is a special built-in function that writes zero or more operandsto a message buffer. The caller controls how the buffer is displayed. Theoperands may be of any type. Furthermore, unlike other built-in functions,undefined operands DO NOT cause the print() function to fail duringevaluation.

View Source
var Product =v1.Product
View Source
var ProvidersAWSSignReqObj =v1.ProvidersAWSSignReqObj
View Source
var RandIntn =v1.RandIntn

RandIntn returns a random number 0 - nMarked non-deterministic because it relies on RNG internally.

View Source
var ReachableBuiltin =v1.ReachableBuiltin
View Source
var ReachablePathsBuiltin =v1.ReachablePathsBuiltin
View Source
var RegexFind =v1.RegexFind

RegexFind takes two strings and a number, the pattern, the value and number of match values toreturn, -1 means all match values.

View Source
var RegexFindAllStringSubmatch =v1.RegexFindAllStringSubmatch
View Source
var RegexIsValid =v1.RegexIsValid
View Source
var RegexMatch =v1.RegexMatch
View Source
var RegexMatchDeprecated =v1.RegexMatchDeprecated

RegexMatchDeprecated declares `re_match` which has been deprecated. Use `regex.match` instead.

View Source
var RegexReplace =v1.RegexReplace
View Source
var RegexSplit =v1.RegexSplit
View Source
var RegexTemplateMatch =v1.RegexTemplateMatch
View Source
var RegoMetadataChain =v1.RegoMetadataChain
View Source
var RegoMetadataRule =v1.RegoMetadataRule

RegoMetadataRule returns the metadata for the active rule

View Source
var RegoParseModule =v1.RegoParseModule
View Source
var RegoRootDocument =v1.RegoRootDocument

RegoRootDocument names the document containing new, to-become-default,features in a future versioned release.

View Source
var RegoV1CompatibleRef =v1.RegoV1CompatibleRef
View Source
var RenderTemplate =v1.RenderTemplate
View Source
var Replace =v1.Replace
View Source
var ReplaceN =v1.ReplaceN
View Source
var ReservedVars =v1.ReservedVars

ReservedVars is the set of names that refer to implicitly ground vars.

View Source
var RootDocumentNames =v1.RootDocumentNames

RootDocumentNames contains the names of top-level documents that can bereferred to in modules and queries.

Note, the schema document is not currently implemented in the evaluator so itis not registered as a root document name (yet).

View Source
var RootDocumentRefs =v1.RootDocumentRefs

RootDocumentRefs contains the prefixes of top-level documents that allnon-local references start with.

View Source
var Round =v1.Round
View Source
var SafetyCheckVisitorParams =v1.SafetyCheckVisitorParams

SafetyCheckVisitorParams defines the AST visitor parameters to use for collectingvariables during the safety check. This has to be exported because it's relied onby the copy propagation implementation in topdown.

View Source
var SchemaRootDocument =v1.SchemaRootDocument

SchemaRootDocument names the document containing external data schemas.

View Source
var SchemaRootRef =v1.SchemaRootRef

SchemaRootRef is a reference to the root of the schema document.

All refs to schema documents are prefixed with this ref. Note, the schemadocument is not currently implemented in the evaluator so it is notregistered as a root document ref (yet).

View Source
var SemVerCompare =v1.SemVerCompare
View Source
var SemVerIsValid =v1.SemVerIsValid
View Source
var SetDiff =v1.SetDiff

SetDiff has been replaced by the minus built-in.

View Source
var Split =v1.Split
View Source
var Sprintf =v1.Sprintf
View Source
var StartsWith =v1.StartsWith
View Source
var StringCount =v1.StringCount
View Source
var StringReverse =v1.StringReverse
View Source
var Substring =v1.Substring
View Source
var ToNumber =v1.ToNumber
View Source
var Trace =v1.Trace
View Source
var TrimLeft =v1.TrimLeft
View Source
var TrimPrefix =v1.TrimPrefix
View Source
var TrimRight =v1.TrimRight
View Source
var TrimSpace =v1.TrimSpace
View Source
var TrimSuffix =v1.TrimSuffix
View Source
var TypeNameBuiltin =v1.TypeNameBuiltin

TypeNameBuiltin returns the type of the input.

View Source
var URLQueryDecode =v1.URLQueryDecode
View Source
var URLQueryDecodeObject =v1.URLQueryDecodeObject
View Source
var URLQueryEncode =v1.URLQueryEncode
View Source
var URLQueryEncodeObject =v1.URLQueryEncodeObject
View Source
var UUIDParse =v1.UUIDParse
View Source
var UUIDRFC4122 =v1.UUIDRFC4122

UUIDRFC4122 returns a version 4 UUID string.Marked non-deterministic because it relies on RNG internally.

View Source
var Union =v1.Union
View Source
var UnitsParse =v1.UnitsParse
View Source
var UnitsParseBytes =v1.UnitsParseBytes
View Source
var Upper =v1.Upper
View Source
var WalkBuiltin =v1.WalkBuiltin
View Source
var Weekday =v1.Weekday
View Source
var Wildcard =v1.Wildcard

Wildcard represents the wildcard variable as defined in the language.

View Source
var YAMLIsValid =v1.YAMLIsValid

YAMLIsValid verifies the input string is a valid YAML document.

View Source
var YAMLMarshal =v1.YAMLMarshal
View Source
var YAMLUnmarshal =v1.YAMLUnmarshal

Functions

funcAsadded inv0.14.0

func As(vValue, xany)error

As converts v into a Go native type referred to by x.

funcBuildAnnotationSetadded inv0.38.0

func BuildAnnotationSet(modules []*Module) (*AnnotationSet,Errors)

funcCompareadded inv0.2.0

func Compare(a, bany)int

Compare returns an integer indicating whether two AST values are less than,equal to, or greater than each other.

If a is less than b, the return value is negative. If a is greater than b,the return value is positive. If a is equal to b, the return value is zero.

Different types are never equal to each other. For comparison purposes, typesare sorted as follows:

nil < Null < Boolean < Number < String < Var < Ref < Array < Object < Set <ArrayComprehension < ObjectComprehension < SetComprehension < Expr < SomeDecl< With < Body < Rule < Import < Package < Module.

Arrays and Refs are equal if and only if both a and b have the same lengthand all corresponding elements are equal. If one element is not equal, thereturn value is the same as for the first differing element. If all elementsare equal but a and b have different lengths, the shorter is considered lessthan the other.

Objects are considered equal if and only if both a and b have the same sorted(key, value) pairs and are of the same length. Other comparisons areconsistent but not defined.

Sets are considered equal if and only if the symmetric difference of a and bis empty.Other comparisons are consistent but not defined.

funcContainsClosuresadded inv0.37.0

func ContainsClosures(vany)bool

ContainsClosures returns true if the Value v contains closures.

funcContainsComprehensionsadded inv0.5.8

func ContainsComprehensions(vany)bool

ContainsComprehensions returns true if the Value v contains comprehensions.

funcContainsRefsadded inv0.5.8

func ContainsRefs(vany)bool

ContainsRefs returns true if the Value v contains refs.

funcCopyadded inv0.20.5

func Copy(xany)any

Copy returns a deep copy of the AST node x. If x is not an AST node, x is returned unmodified.

funcHasInternedIntNumberTermadded inv1.0.0

func HasInternedIntNumberTerm(iint)bool

funcIsComprehensionadded inv0.5.11

func IsComprehension(xValue)bool

IsComprehension returns true if the supplied value is a comprehension.

funcIsConstantadded inv0.4.9

func IsConstant(vValue)bool

IsConstant returns true if the AST value is constant.

funcIsErroradded inv0.4.0

func IsError(codestring, errerror)bool

IsError returns true if err is an AST error with code.

funcIsFutureKeywordadded inv0.64.0

func IsFutureKeyword(sstring)bool

funcIsInKeywordsadded inv0.69.0

func IsInKeywords(sstring, keywords []string)bool

funcIsKeywordadded inv0.2.2

func IsKeyword(sstring)bool

IsKeyword returns true if s is a language keyword.

funcIsKeywordInRegoVersionadded inv0.67.0

func IsKeywordInRegoVersion(sstring, regoVersionRegoVersion)bool

IsKeywordInRegoVersion returns true if s is a language keyword.

funcIsScalaradded inv0.2.0

func IsScalar(vValue)bool

IsScalar returns true if the AST value is a scalar.

funcIsUnknownValueErradded inv0.9.0

func IsUnknownValueErr(errerror)bool

IsUnknownValueErr returns true if the err is an UnknownValueErr.

funcIsValidImportPathadded inv0.3.0

func IsValidImportPath(vValue) (errerror)

IsValidImportPath returns an error indicating if the import path is invalid.If the import path is valid, err is nil.

funcIsVarCompatibleStringadded inv0.58.0

func IsVarCompatibleString(sstring)bool

funcJSONadded inv0.4.9

func JSON(vValue) (any,error)

JSON returns the JSON representation of v. The value must not contain anyrefs or terms that require evaluation (e.g., vars, comprehensions, etc.)

funcJSONWithOptadded inv0.27.1

func JSONWithOpt(vValue, optJSONOpt) (any,error)

JSONWithOpt returns the JSON representation of v. The value must not contain anyrefs or terms that require evaluation (e.g., vars, comprehensions, etc.)

funcKeywordsForRegoVersionadded inv0.69.0

func KeywordsForRegoVersion(vRegoVersion) []string

funcLoadCapabilitiesVersionsadded inv0.40.0

func LoadCapabilitiesVersions() ([]string,error)

LoadCapabilitiesVersions loads all capabilities versions

funcMustJSONadded inv0.25.0

func MustJSON(vValue)any

MustJSON returns the JSON representation of v. The value must not contain anyrefs or terms that require evaluation (e.g., vars, comprehensions, etc.) Ifthe conversion fails, this function will panic. This function is mostly fortest purposes.

funcParseStatements

func ParseStatements(filename, inputstring) ([]Statement, []*Comment,error)

ParseStatements is deprecated. Use ParseStatementWithOpts instead.

funcParseStatementsWithOptsadded inv0.28.0

func ParseStatementsWithOpts(filename, inputstring, poptsParserOptions) ([]Statement, []*Comment,error)

ParseStatementsWithOpts returns a slice of parsed statements. This is thedefault return value from the parser.

funcPrettyadded inv0.7.0

func Pretty(wio.Writer, xany)

Pretty writes a pretty representation of the AST rooted at x to w.

This is function is intended for debug purposes when inspecting ASTs.

funcRegisterBuiltin

func RegisterBuiltin(b *Builtin)

RegisterBuiltin adds a new built-in function to the registry.

funcTransformadded inv0.2.0

func Transform(tTransformer, xany) (any,error)

Transform iterates the AST and calls the Transform function on theTransformer t for x before recursing.

funcTransformComprehensionsadded inv0.5.8

func TransformComprehensions(xany, f func(any) (Value,error)) (any,error)

TransformComprehensions calls the functio nf on all comprehensions under x.

funcTransformRefsadded inv0.2.0

func TransformRefs(xany, f func(Ref) (Value,error)) (any,error)

TransformRefs calls the function f on all references under x.

funcTransformVarsadded inv0.7.0

func TransformVars(xany, f func(Var) (Value,error)) (any,error)

TransformVars calls the function f on all vars under x.

funcTypeNameadded inv0.3.0

func TypeName(xany)string

TypeName returns a human readable name for the AST element type.

funcValueToInterfaceadded inv0.4.9

func ValueToInterface(vValue, resolverResolver) (any,error)

ValueToInterface returns the Go representation of an AST value. The ASTvalue should not contain any values that require evaluation (e.g., vars,comprehensions, etc.)

funcWalkdeprecated

func Walk(vVisitor, xany)

Walk iterates the AST by calling the Visit function on the Visitorv for x before recursing.

Deprecated: use GenericVisitor.Walk

funcWalkBeforeAndAfterdeprecatedadded inv0.7.0

func WalkBeforeAndAfter(vBeforeAndAfterVisitor, xany)

WalkBeforeAndAfter iterates the AST by calling the Visit function on theVisitor v for x before recursing.

Deprecated: use GenericVisitor.Walk

funcWalkBodiesadded inv0.2.0

func WalkBodies(xany, f func(Body)bool)

WalkBodies calls the function f on all bodies under x. If the function freturns true, AST nodes under the last node will not be visited.

funcWalkClosures

func WalkClosures(xany, f func(any)bool)

WalkClosures calls the function f on all closures under x. If the function freturns true, AST nodes under the last node will not be visited.

funcWalkExprsadded inv0.4.9

func WalkExprs(xany, f func(*Expr)bool)

WalkExprs calls the function f on all expressions under x. If the function freturns true, AST nodes under the last node will not be visited.

funcWalkNodesadded inv0.9.2

func WalkNodes(xany, f func(Node)bool)

WalkNodes calls the function f on all nodes under x. If the function freturns true, AST nodes under the last node will not be visited.

funcWalkRefs

func WalkRefs(xany, f func(Ref)bool)

WalkRefs calls the function f on all references under x. If the function freturns true, AST nodes under the last node will not be visited.

funcWalkRulesadded inv0.4.10

func WalkRules(xany, f func(*Rule)bool)

WalkRules calls the function f on all rules under x. If the function freturns true, AST nodes under the last node will not be visited.

funcWalkTermsadded inv0.7.0

func WalkTerms(xany, f func(*Term)bool)

WalkTerms calls the function f on all terms under x. If the function freturns true, AST nodes under the last node will not be visited.

funcWalkVarsadded inv0.2.1

func WalkVars(xany, f func(Var)bool)

WalkVars calls the function f on all vars under x. If the function freturns true, AST nodes under the last node will not be visited.

funcWalkWithsadded inv0.4.1

func WalkWiths(xany, f func(*With)bool)

WalkWiths calls the function f on all with modifiers under x. If the function freturns true, AST nodes under the last node will not be visited.

Types

typeAnnotationSetadded inv0.38.0

type AnnotationSet =v1.AnnotationSet

typeAnnotationsadded inv0.28.0

type Annotations =v1.Annotations

Annotations represents metadata attached to other AST nodes such as rules.

typeAnnotationsRefadded inv0.38.0

type AnnotationsRef =v1.AnnotationsRef

funcNewAnnotationsRefadded inv0.40.0

func NewAnnotationsRef(a *Annotations) *AnnotationsRef

typeAnnotationsRefSetadded inv0.49.0

type AnnotationsRefSet =v1.AnnotationsRefSet

typeArgsadded inv0.5.0

type Args =v1.Args

Args represents zero or more arguments to a rule.

typeArray

type Array =v1.Array

Array represents an array as defined by the language. Arrays are similar to thesame types as defined by JSON with the exception that they can contain Varsand References.

funcNewArrayadded inv0.23.0

func NewArray(a ...*Term) *Array

NewArray creates an Array with the terms provided. The array willuse the provided term slice.

typeArrayComprehension

type ArrayComprehension =v1.ArrayComprehension

ArrayComprehension represents an array comprehension as defined in the language.

typeAuthorAnnotationadded inv0.38.0

type AuthorAnnotation =v1.AuthorAnnotation

typeBeforeAfterVisitoradded inv0.17.0

type BeforeAfterVisitor =v1.BeforeAfterVisitor

BeforeAfterVisitor provides a utility to walk over AST nodes usingclosures. If the before closure returns true, the visitor will notwalk over AST nodes under x. The after closure is invoked alwaysafter visiting a node.

funcNewBeforeAfterVisitoradded inv0.17.0

func NewBeforeAfterVisitor(before func(xany)bool, after func(xany)) *BeforeAfterVisitor

NewBeforeAfterVisitor returns a new BeforeAndAfterVisitor thatwill invoke the functions before and after AST nodes.

typeBeforeAndAfterVisitordeprecatedadded inv0.7.0

type BeforeAndAfterVisitor =v1.BeforeAndAfterVisitor

BeforeAndAfterVisitor wraps Visitor to provide hooks for being called beforeand after the AST has been visited.

Deprecated: use GenericVisitor or another visitor implementation

typeBody

type Body =v1.Body

Body represents one or more expressions contained inside a rule or userfunction.

funcMustParseBody

func MustParseBody(inputstring)Body

MustParseBody returns a parsed body.If an error occurs during parsing, panic.

funcMustParseBodyWithOptsadded inv0.37.0

func MustParseBodyWithOpts(inputstring, optsParserOptions)Body

MustParseBodyWithOpts returns a parsed body.If an error occurs during parsing, panic.

funcNewBodyadded inv0.2.0

func NewBody(exprs ...*Expr)Body

NewBody returns a new Body containing the given expressions. The indices ofthe immediate expressions will be reset.

funcParseBody

func ParseBody(inputstring) (Body,error)

ParseBody returns exactly one body.If multiple bodies are parsed, an error is returned.

funcParseBodyWithOptsadded inv0.34.0

func ParseBodyWithOpts(inputstring, poptsParserOptions) (Body,error)

ParseBodyWithOpts returns exactly one body. It does _not_ set SkipRules: true on its own,but respects whatever ParserOptions it's been given.

typeBoolean

type Boolean =v1.Boolean

Boolean represents a boolean value defined by JSON.

typeBuiltin

type Builtin =v1.Builtin

Builtin represents a built-in function supported by OPA. Every built-infunction is uniquely identified by a name.

typeCalladded inv0.7.0

type Call =v1.Call

Call represents as function call in the language.

typeCapabilitiesadded inv0.23.0

type Capabilities =v1.Capabilities

Capabilities defines a structure containing data that describes the capabilitiesor features supported by a particular version of OPA.

funcCapabilitiesForThisVersionadded inv0.23.0

func CapabilitiesForThisVersion() *Capabilities

CapabilitiesForThisVersion returns the capabilities of this version of OPA.

funcLoadCapabilitiesFileadded inv0.40.0

func LoadCapabilitiesFile(filestring) (*Capabilities,error)

LoadCapabilitiesFile loads a JSON serialized capabilities structure from a file.

funcLoadCapabilitiesJSONadded inv0.23.0

func LoadCapabilitiesJSON(rio.Reader) (*Capabilities,error)

LoadCapabilitiesJSON loads a JSON serialized capabilities structure from the reader r.

funcLoadCapabilitiesVersionadded inv0.40.0

func LoadCapabilitiesVersion(versionstring) (*Capabilities,error)

LoadCapabilitiesVersion loads a JSON serialized capabilities structure from the specific version.

typeCommentadded inv0.4.0

type Comment =v1.Comment

Comment contains the raw text from the comment in the definition.

funcNewCommentadded inv0.4.0

func NewComment(text []byte) *Comment

NewComment returns a new Comment object.

typeCompileOptsadded inv0.34.0

type CompileOpts =v1.CompileOpts

CompileOpts defines a set of options for the compiler.

typeCompiler

type Compiler =v1.Compiler

Compiler contains the state of a compilation process.

funcCompileModulesadded inv0.10.2

func CompileModules(modules map[string]string) (*Compiler,error)

CompileModules takes a set of Rego modules represented as strings andcompiles them for evaluation. The keys of the map are used as filenames.

funcCompileModulesWithOptadded inv0.34.0

func CompileModulesWithOpt(modules map[string]string, optsCompileOpts) (*Compiler,error)

CompileModulesWithOpt takes a set of Rego modules represented as strings andcompiles them for evaluation. The keys of the map are used as filenames.

funcMustCompileModulesadded inv0.10.2

func MustCompileModules(modules map[string]string) *Compiler

MustCompileModules compiles a set of Rego modules represented as strings. Ifthe compilation process fails, this function panics.

funcMustCompileModulesWithOptsadded inv0.34.0

func MustCompileModulesWithOpts(modules map[string]string, optsCompileOpts) *Compiler

MustCompileModulesWithOpts compiles a set of Rego modules represented as strings. Ifthe compilation process fails, this function panics.

funcNewCompiler

func NewCompiler() *Compiler

NewCompiler returns a new empty compiler.

typeCompilerEvalModeadded inv0.58.0

type CompilerEvalMode =v1.CompilerEvalMode

CompilerEvalMode allows toggling certain stages that are onlyneeded for certain modes, Concretely, only "topdown" mode willhave the compiler build comprehension and rule indices.

typeCompilerStageadded inv0.10.6

type CompilerStage =v1.CompilerStage

CompilerStage defines the interface for stages in the compiler.

typeCompilerStageDefinitionadded inv0.11.0

type CompilerStageDefinition =v1.CompilerStageDefinition

CompilerStageDefinition defines a compiler stage

typeComprehensionIndexadded inv0.20.0

type ComprehensionIndex =v1.ComprehensionIndex

ComprehensionIndex specifies how the comprehension term can be indexed. The keystell the evaluator what variables to use for indexing. In the future, the indexcould be expanded with more information that would allow the evaluator to indexa larger fragment of comprehensions (e.g., by closing over variables in the outerquery.)

typeDocKind

type DocKind =v1.DocKind

DocKind represents the collection of document types that can be produced by rules.

typeErroradded inv0.2.0

type Error =v1.Error

Error represents a single error caught during parsing, compiling, etc.

funcNewErroradded inv0.2.0

func NewError(codestring, loc *Location, fstring, a ...any) *Error

NewError returns a new Error object.

typeErrorDetailsadded inv0.4.9

type ErrorDetails =v1.ErrorDetails

ErrorDetails defines the interface for detailed error messages.

typeErrorsadded inv0.2.0

type Errors =v1.Errors

Errors represents a series of errors encountered during parsing, compiling,etc.

funcCheckPathConflictsadded inv0.10.4

func CheckPathConflicts(c *Compiler, exists func([]string) (bool,error))Errors

CheckPathConflicts returns a set of errors indicating paths thatare in conflict with the result of the provided callable.

typeEveryadded inv0.37.0

type Every =v1.Every

typeExpr

type Expr =v1.Expr

Expr represents a single expression contained inside the body of a rule.

funcMustParseExpradded inv0.2.0

func MustParseExpr(inputstring) *Expr

MustParseExpr returns a parsed expression.If an error occurs during parsing, panic.

funcNewBuiltinExpr

func NewBuiltinExpr(terms ...*Term) *Expr

NewBuiltinExpr creates a new Expr object with the supplied terms.The builtin operator must be the first term.

funcNewExpradded inv0.2.1

func NewExpr(termsany) *Expr

NewExpr returns a new Expr object.

funcParseExpradded inv0.2.0

func ParseExpr(inputstring) (*Expr,error)

ParseExpr returns exactly one expression.If multiple expressions are parsed, an error is returned.

typeFlatAnnotationsRefSetadded inv0.49.0

type FlatAnnotationsRefSet =v1.FlatAnnotationsRefSet

typeGenericTransformeradded inv0.2.0

type GenericTransformer =v1.GenericTransformer

GenericTransformer implements the Transformer interface to provide a utilityto transform AST nodes using a closure.

funcNewGenericTransformeradded inv0.5.11

func NewGenericTransformer(f func(xany) (any,error)) *GenericTransformer

NewGenericTransformer returns a new GenericTransformer that will transformAST nodes using the function f.

typeGenericVisitor

type GenericVisitor =v1.GenericVisitor

GenericVisitor provides a utility to walk over AST nodes using aclosure. If the closure returns true, the visitor will not walkover AST nodes under x.

funcNewGenericVisitoradded inv0.4.1

func NewGenericVisitor(f func(xany)bool) *GenericVisitor

NewGenericVisitor returns a new GenericVisitor that will invoke the functionf on AST nodes.

typeGraphadded inv0.5.0

type Graph =v1.Graph

Graph represents the graph of dependencies between rules.

funcNewGraphadded inv0.5.0

func NewGraph(modules map[string]*Module, list func(Ref) []*Rule) *Graph

NewGraph returns a new Graph based on modules. The list function must returnthe rules referred to directly by the ref.

typeGraphTraversaladded inv0.12.0

type GraphTraversal =v1.GraphTraversal

GraphTraversal is a Traversal that understands the dependency graph

funcNewGraphTraversaladded inv0.12.0

func NewGraphTraversal(graph *Graph) *GraphTraversal

NewGraphTraversal returns a Traversal for the dependency graph

typeHeadadded inv0.2.0

type Head =v1.Head

Head represents the head of a rule.

funcNewHeadadded inv0.4.1

func NewHead(nameVar, args ...*Term) *Head

NewHead returns a new Head object. If args are provided, the first will beused for the key and the second will be used for the value.

funcRefHeadadded inv0.46.0

func RefHead(refRef, args ...*Term) *Head

RefHead returns a new Head object with the passed Ref. If args are provided,the first will be used for the value.

funcVarHeadadded inv0.57.0

func VarHead(nameVar, location *Location, jsonOpts *astJSON.Options) *Head

VarHead creates a head object, initializes its Name, Location, and Options,and returns the new head.

typeImport

type Import =v1.Import

Import represents a dependency on a document outside of the policynamespace. Imports are optional.

funcMustParseImportsadded inv0.2.2

func MustParseImports(inputstring) []*Import

MustParseImports returns a slice of imports.If an error occurs during parsing, panic.

funcParseImportsadded inv0.2.2

func ParseImports(inputstring) ([]*Import,error)

ParseImports returns a slice of Import objects.

typeIndexResultadded inv0.4.10

type IndexResult =v1.IndexResult

IndexResult contains the result of an index lookup.

funcNewIndexResultadded inv0.4.10

func NewIndexResult(kindRuleKind) *IndexResult

NewIndexResult returns a new IndexResult object.

typeJSONOptadded inv0.27.1

type JSONOpt =v1.JSONOpt

JSONOpt defines parameters for AST to JSON conversion.

typeLocation

type Location =v1.Location

Location records a position in source code.

funcNewLocation

func NewLocation(text []byte, filestring, rowint, colint) *Location

NewLocation returns a new Location object.

typeModule

type Module =v1.Module

Module represents a collection of policies (defined by rules)within a namespace (defined by the package) and optionaldependencies on external documents (defined by imports).

funcMustParseModule

func MustParseModule(inputstring) *Module

MustParseModule returns a parsed module.If an error occurs during parsing, panic.

funcMustParseModuleWithOptsadded inv0.37.0

func MustParseModuleWithOpts(inputstring, optsParserOptions) *Module

MustParseModuleWithOpts returns a parsed module.If an error occurs during parsing, panic.

funcParseModule

func ParseModule(filename, inputstring) (*Module,error)

ParseModule returns a parsed Module object.For details on Module objects and their fields, see policy.go.Empty input will return nil, nil.

funcParseModuleWithOptsadded inv0.28.0

func ParseModuleWithOpts(filename, inputstring, poptsParserOptions) (*Module,error)

ParseModuleWithOpts returns a parsed Module object, and has an additional input ParserOptionsFor details on Module objects and their fields, see policy.go.Empty input will return nil, nil.

typeModuleLoaderadded inv0.3.0

type ModuleLoader =v1.ModuleLoader

ModuleLoader defines the interface that callers can implement to enable lazyloading of modules during compilation.

typeModuleTreeNode

type ModuleTreeNode =v1.ModuleTreeNode

ModuleTreeNode represents a node in the module tree. The moduletree is keyed by the package path.

typeNodeadded inv0.9.2

type Node =v1.Node

Node represents a node in an AST. Nodes may be statements in a policy moduleor elements of an ad-hoc query, expression, etc.

typeNull

type Null =v1.Null

Null represents the null value defined by JSON.

typeNumber

type Number =v1.Number

Number represents a numeric value as defined by JSON.

typeObject

type Object =v1.Object

Object represents an object as defined by the language.

funcLazyObjectadded inv0.47.0

func LazyObject(blob map[string]any)Object

funcNewObjectadded inv0.6.0

func NewObject(t ...[2]*Term)Object

NewObject creates a new Object with t.

typeObjectComprehensionadded inv0.5.2

type ObjectComprehension =v1.ObjectComprehension

ObjectComprehension represents an object comprehension as defined in the language.

typeObjectKeysIteratoradded inv0.43.0

type ObjectKeysIterator =v1.ObjectKeysIterator

NOTE(philipc): The only way to get an ObjectKeyIterator should befrom an Object. This ensures that the iterator can have implementation-specific details internally, with no contracts except to the verylimited interface.

typePackage

type Package =v1.Package

Package represents the namespace of the documents producedby rules inside the module.

funcMustParsePackageadded inv0.2.2

func MustParsePackage(inputstring) *Package

MustParsePackage returns a Package.If an error occurs during parsing, panic.

funcParsePackageadded inv0.2.2

func ParsePackage(inputstring) (*Package,error)

ParsePackage returns exactly one Package.If multiple statements are parsed, an error is returned.

typeParseradded inv0.19.0

type Parser =v1.Parser

Parser is used to parse Rego statements.

funcNewParseradded inv0.19.0

func NewParser() *Parser

NewParser creates and initializes a Parser.

typeParserErrorDetailadded inv0.15.0

type ParserErrorDetail =v1.ParserErrorDetail

ParserErrorDetail holds additional details for parser errors.

typeParserOptionsadded inv0.28.0

type ParserOptions =v1.ParserOptions

ParserOptions defines the options for parsing Rego statements.

typeQueryCompileradded inv0.2.2

type QueryCompiler =v1.QueryCompiler

QueryCompiler defines the interface for compiling ad-hoc queries.

typeQueryCompilerStageadded inv0.7.0

type QueryCompilerStage =v1.QueryCompilerStage

QueryCompilerStage defines the interface for stages in the query compiler.

typeQueryCompilerStageDefinitionadded inv0.11.0

type QueryCompilerStageDefinition =v1.QueryCompilerStageDefinition

QueryCompilerStageDefinition defines a QueryCompiler stage

typeQueryContextadded inv0.2.2

type QueryContext =v1.QueryContext

QueryContext contains contextual information for running an ad-hoc query.

Ad-hoc queries can be run in the context of a package and imports may beincluded to provide concise access to data.

funcNewQueryContextadded inv0.2.2

func NewQueryContext() *QueryContext

NewQueryContext returns a new QueryContext object.

typeQueryIterator

type QueryIterator =v1.QueryIterator

QueryIterator defines the interface for querying AST documents with references.

typeRef

type Ref =v1.Ref

Ref represents a reference as defined by the language.

funcEmptyRef

func EmptyRef()Ref

EmptyRef returns a new, empty reference.

funcMustParseRef

func MustParseRef(inputstring)Ref

MustParseRef returns a parsed reference.If an error occurs during parsing, panic.

funcParseRef

func ParseRef(inputstring) (Ref,error)

ParseRef returns exactly one reference.

funcPtrRefadded inv0.10.4

func PtrRef(head *Term, sstring) (Ref,error)

PtrRef returns a new reference against the head for the pointers. Path components in the pointer are unescaped.

typeRefErrInvalidDetailadded inv0.5.2

type RefErrInvalidDetail =v1.RefErrInvalidDetail

RefErrInvalidDetail describes an undefined reference error where the referencedvalue does not support the reference operand (e.g., missing object key,invalid key type, etc.)

typeRefErrUnsupportedDetailadded inv0.5.2

type RefErrUnsupportedDetail =v1.RefErrUnsupportedDetail

RefErrUnsupportedDetail describes an undefined reference error where thereferenced value does not support dereferencing (e.g., scalars).

typeRegoVersionadded inv0.60.0

type RegoVersion =v1.RegoVersion

RegoVersion defines the Rego syntax requirements for a module.

funcRegoVersionFromIntadded inv0.64.0

func RegoVersionFromInt(iint)RegoVersion

typeRelatedResourceAnnotationadded inv0.38.0

type RelatedResourceAnnotation =v1.RelatedResourceAnnotation

typeResolveradded inv0.4.9

type Resolver =v1.Resolver

Resolver defines the interface for resolving references to native Go values.

typeRule

type Rule =v1.Rule

Rule represents a rule as defined in the language. Rules define thecontent of documents that represent policy decisions.

funcMustParseRule

func MustParseRule(inputstring) *Rule

MustParseRule returns a parsed rule.If an error occurs during parsing, panic.

funcMustParseRuleWithOptsadded inv0.69.0

func MustParseRuleWithOpts(inputstring, optsParserOptions) *Rule

MustParseRuleWithOpts returns a parsed rule.If an error occurs during parsing, panic.

funcParseCompleteDocRuleFromAssignmentExpradded inv0.14.0

func ParseCompleteDocRuleFromAssignmentExpr(module *Module, lhs, rhs *Term) (*Rule,error)

ParseCompleteDocRuleFromAssignmentExpr returns a rule if the expression canbe interpreted as a complete document definition declared with the assignmentoperator.

funcParseCompleteDocRuleFromEqExpradded inv0.5.6

func ParseCompleteDocRuleFromEqExpr(module *Module, lhs, rhs *Term) (*Rule,error)

ParseCompleteDocRuleFromEqExpr returns a rule if the expression can beinterpreted as a complete document definition.

funcParseCompleteDocRuleWithDotsFromTermadded inv0.46.0

func ParseCompleteDocRuleWithDotsFromTerm(module *Module, term *Term) (*Rule,error)

funcParsePartialObjectDocRuleFromEqExpradded inv0.5.6

func ParsePartialObjectDocRuleFromEqExpr(module *Module, lhs, rhs *Term) (*Rule,error)

ParsePartialObjectDocRuleFromEqExpr returns a rule if the expression can beinterpreted as a partial object document definition.

funcParsePartialSetDocRuleFromTermadded inv0.5.6

func ParsePartialSetDocRuleFromTerm(module *Module, term *Term) (*Rule,error)

ParsePartialSetDocRuleFromTerm returns a rule if the term can be interpretedas a partial set document definition.

funcParseRule

func ParseRule(inputstring) (*Rule,error)

ParseRule returns exactly one rule.If multiple rules are parsed, an error is returned.

funcParseRuleFromBodyadded inv0.3.0

func ParseRuleFromBody(module *Module, bodyBody) (*Rule,error)

ParseRuleFromBody returns a rule if the body can be interpreted as a ruledefinition. Otherwise, an error is returned.

funcParseRuleFromCallEqExpradded inv0.7.0

func ParseRuleFromCallEqExpr(module *Module, lhs, rhs *Term) (*Rule,error)

ParseRuleFromCallEqExpr returns a rule if the term can be interpreted as afunction definition (e.g., f(x) = y => f(x) = y { true }).

funcParseRuleFromCallExpradded inv0.5.9

func ParseRuleFromCallExpr(module *Module, terms []*Term) (*Rule,error)

ParseRuleFromCallExpr returns a rule if the terms can be interpreted as afunction returning true or some value (e.g., f(x) => f(x) = true { true }).

funcParseRuleFromExpradded inv0.5.6

func ParseRuleFromExpr(module *Module, expr *Expr) (*Rule,error)

ParseRuleFromExpr returns a rule if the expression can be interpreted as arule definition.

funcParseRuleWithOptsadded inv0.46.0

func ParseRuleWithOpts(inputstring, optsParserOptions) (*Rule,error)

ParseRuleWithOpts returns exactly one rule.If multiple rules are parsed, an error is returned.

typeRuleIndexadded inv0.4.9

type RuleIndexv1.RuleIndex

RuleIndex defines the interface for rule indices.

typeRuleKindadded inv0.46.0

type RuleKind =v1.RuleKind

typeRuleSetadded inv0.4.9

type RuleSet =v1.RuleSet

RuleSet represents a collection of rules that produce a virtual document.

funcNewRuleSetadded inv0.4.9

func NewRuleSet(rules ...*Rule)RuleSet

NewRuleSet returns a new RuleSet containing the given rules.

typeRulesOptionsadded inv0.34.0

type RulesOptions =v1.RulesOptions

RulesOptions defines the options for retrieving rules by Ref from thecompiler.

typeSchemaAnnotationadded inv0.28.0

type SchemaAnnotation =v1.SchemaAnnotation

SchemaAnnotation contains a schema declaration for the document identified by the path.

typeSchemaSetadded inv0.27.0

type SchemaSet =v1.SchemaSet

SchemaSet holds a map from a path to a schema.

funcNewSchemaSetadded inv0.28.0

func NewSchemaSet() *SchemaSet

NewSchemaSet returns an empty SchemaSet.

typeSetadded inv0.2.0

type Set =v1.Set

Set represents a set as defined by the language.

funcNewSetadded inv0.6.0

func NewSet(t ...*Term)Set

NewSet returns a new Set containing t.

typeSetComprehensionadded inv0.5.2

type SetComprehension =v1.SetComprehension

SetComprehension represents a set comprehension as defined in the language.

typeSomeDecladded inv0.11.0

type SomeDecl =v1.SomeDecl

SomeDecl represents a variable declaration statement. The symbols are variables.

typeStatement

type Statement =v1.Statement

Statement represents a single statement in a policy module.

funcMustParseStatement

func MustParseStatement(inputstring)Statement

MustParseStatement returns exactly one statement.If an error occurs during parsing, panic.

funcMustParseStatementWithOptsadded inv0.69.0

func MustParseStatementWithOpts(inputstring, poptsParserOptions)Statement

funcMustParseStatements

func MustParseStatements(inputstring) []Statement

MustParseStatements returns a slice of parsed statements.If an error occurs during parsing, panic.

funcParseStatement

func ParseStatement(inputstring) (Statement,error)

ParseStatement returns exactly one statement.A statement might be a term, expression, rule, etc. Regardless,this function expects *exactly* one statement. If multiplestatements are parsed, an error is returned.

funcParseStatementWithOptsadded inv0.69.0

func ParseStatementWithOpts(inputstring, poptsParserOptions) (Statement,error)

typeString

type String =v1.String

String represents a string value as defined by JSON.

typeTerm

type Term =v1.Term

Term is an argument to a function.

funcArrayComprehensionTerm

func ArrayComprehensionTerm(term *Term, bodyBody) *Term

ArrayComprehensionTerm creates a new Term with an ArrayComprehension value.

funcArrayTerm

func ArrayTerm(a ...*Term) *Term

ArrayTerm creates a new Term with an Array value.

funcBooleanTerm

func BooleanTerm(bbool) *Term

BooleanTerm creates a new Term with a Boolean value.

funcCallTermadded inv0.7.0

func CallTerm(terms ...*Term) *Term

CallTerm returns a new Term with a Call value defined by terms. The firstterm is the operator and the rest are operands.

funcFloatNumberTermadded inv0.3.0

func FloatNumberTerm(ffloat64) *Term

FloatNumberTerm creates a new Term with a floating point Number value.

funcIntNumberTermadded inv0.3.0

func IntNumberTerm(iint) *Term

IntNumberTerm creates a new Term with an integer Number value.

funcInternedBooleanTermadded inv1.0.0

func InternedBooleanTerm(bbool) *Term

funcInternedIntNumberTermadded inv1.0.0

func InternedIntNumberTerm(iint) *Term

InternedIntNumberTerm returns a term with the given integer value. The term iscached between -1 to 512, and for values outside of that range, this functionis equivalent to ast.IntNumberTerm.

funcItem

func Item(key, value *Term) [2]*Term

Item is a helper for constructing an tuple containing two Termsrepresenting a key/value pair in an Object.

funcMustParseTerm

func MustParseTerm(inputstring) *Term

MustParseTerm returns a parsed term.If an error occurs during parsing, panic.

funcNewTermadded inv0.2.1

func NewTerm(vValue) *Term

NewTerm returns a new Term object.

funcNullTerm

func NullTerm() *Term

NullTerm creates a new Term with a Null value.

funcNumberTerm

func NumberTerm(njson.Number) *Term

NumberTerm creates a new Term with a Number value.

funcObjectComprehensionTermadded inv0.5.2

func ObjectComprehensionTerm(key, value *Term, bodyBody) *Term

ObjectComprehensionTerm creates a new Term with an ObjectComprehension value.

funcObjectTerm

func ObjectTerm(o ...[2]*Term) *Term

ObjectTerm creates a new Term with an Object value.

funcParseTerm

func ParseTerm(inputstring) (*Term,error)

ParseTerm returns exactly one term.If multiple terms are parsed, an error is returned.

funcRefTerm

func RefTerm(r ...*Term) *Term

RefTerm creates a new Term with a Ref value.

funcSetComprehensionTermadded inv0.5.2

func SetComprehensionTerm(term *Term, bodyBody) *Term

SetComprehensionTerm creates a new Term with an SetComprehension value.

funcSetTermadded inv0.2.0

func SetTerm(t ...*Term) *Term

funcStringTerm

func StringTerm(sstring) *Term

StringTerm creates a new Term with a String value.

funcUIntNumberTermadded inv0.22.0

func UIntNumberTerm(uuint64) *Term

UIntNumberTerm creates a new Term with an unsigned integer Number value.

funcVarTerm

func VarTerm(vstring) *Term

VarTerm creates a new Term with a Variable value.

typeTransformeradded inv0.2.0

type Transformer =v1.Transformer

Transformer defines the interface for transforming AST elements. If thetransformer returns nil and does not indicate an error, the AST element willbe set to nil and no transformations will be applied to children of theelement.

typeTreeNodeadded inv0.5.0

type TreeNode =v1.TreeNode

TreeNode represents a node in the rule tree. The rule tree is keyed byrule path.

funcNewRuleTreeadded inv0.2.0

func NewRuleTree(mtree *ModuleTreeNode) *TreeNode

NewRuleTree returns a new TreeNode that represents the rootof the rule tree populated with the given rules.

typeTypeEnvadded inv0.4.9

type TypeEnv =v1.TypeEnv

TypeEnv contains type info for static analysis such as type checking.

typeUnificationErrDetailadded inv0.4.9

type UnificationErrDetail =v1.UnificationErrDetail

UnificationErrDetail describes a type mismatch error when two values areunified (e.g., x = [1,2,y]).

typeUnknownValueErradded inv0.9.0

type UnknownValueErr =v1.UnknownValueErr

UnknownValueErr indicates a ValueResolver was unable to resolve a referencebecause the reference refers to an unknown value.

typeValue

type Value =v1.Value

Value declares the common interface for all Term values. Every kind of Term valuein the language is represented as a type that implements this interface:

- Null, Boolean, Number, String- Object, Array, Set- Variables, References- Array, Set, and Object Comprehensions- Calls

funcInterfaceToValue

func InterfaceToValue(xany) (Value,error)

InterfaceToValue converts a native Go value x to a Value.

funcMustInterfaceToValueadded inv0.4.5

func MustInterfaceToValue(xany)Value

MustInterfaceToValue converts a native Go value x to a Value. If theconversion fails, this function will panic. This function is mostly for testpurposes.

funcValueFromReaderadded inv0.14.0

func ValueFromReader(rio.Reader) (Value,error)

ValueFromReader returns an AST value from a JSON serialized value in the reader.

typeValueMapadded inv0.2.0

type ValueMap =v1.ValueMap

ValueMap represents a key/value map between AST term values. Any type of termcan be used as a key in the map.

funcNewValueMapadded inv0.2.0

func NewValueMap() *ValueMap

NewValueMap returns a new ValueMap.

typeValueResolveradded inv0.4.9

type ValueResolver =v1.ValueResolver

ValueResolver defines the interface for resolving references to AST values.

typeVar

type Var =v1.Var

Var represents a variable as defined by the language.

typeVarSet

type VarSet =v1.VarSet

VarSet represents a set of variables.

funcNewVarSet

func NewVarSet(vs ...Var)VarSet

NewVarSet returns a new VarSet containing the specified variables.

funcOutputVarsFromBodyadded inv0.20.0

func OutputVarsFromBody(c *Compiler, bodyBody, safeVarSet)VarSet

OutputVarsFromBody returns all variables which are the "output" forthe given body. For safety checks this means that they would bemade safe by the body.

funcOutputVarsFromExpradded inv0.20.0

func OutputVarsFromExpr(c *Compiler, expr *Expr, safeVarSet)VarSet

OutputVarsFromExpr returns all variables which are the "output" forthe given expression. For safety checks this means that they would bemade safe by the expr.

funcUnify

func Unify(safeVarSet, a *Term, b *Term)VarSet

Unify returns a set of variables that will be unified when the equality expression defined byterms a and b is evaluated. The unifier assumes that variables in the VarSet safe are alreadyunified.

typeVarVisitoradded inv0.3.0

type VarVisitor =v1.VarVisitor

VarVisitor walks AST nodes under a given node and collects all encounteredvariables. The collected variables can be controlled by specifyingVarVisitorParams when creating the visitor.

funcNewVarVisitoradded inv0.3.0

func NewVarVisitor() *VarVisitor

NewVarVisitor returns a new VarVisitor object.

typeVarVisitorParamsadded inv0.3.0

type VarVisitorParams =v1.VarVisitorParams

VarVisitorParams contains settings for a VarVisitor.

typeVersionIndexadded inv0.59.0

type VersionIndex =v1.VersionIndex

VersonIndex contains an index from built-in function name, language feature,and future rego keyword to version number. During the build, this is used tocreate an index of the minimum version required for the built-in/feature/kw.

typeVisitordeprecated

type Visitor =v1.Visitor

Visitor defines the interface for iterating AST elements. The Visit functioncan return a Visitor w which will be used to visit the children of the ASTelement v. If the Visit function returns nil, the children will not bevisited.

Deprecated: use GenericVisitor or another visitor implementation

typeWasmABIVersionadded inv0.27.0

type WasmABIVersion =v1.WasmABIVersion

WasmABIVersion captures the Wasm ABI version. Its `Minor` version is indicatingbackwards-compatible changes.

typeWithadded inv0.4.1

type With =v1.With

With represents a modifier on an expression.

Source Files

View all Source files

Directories

PathSynopsis
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.
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.
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.
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2026 Movatter.jp