ast
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
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
- Variables
- func As(v Value, x any) error
- func BuildAnnotationSet(modules []*Module) (*AnnotationSet, Errors)
- func Compare(a, b any) int
- func ContainsClosures(v any) bool
- func ContainsComprehensions(v any) bool
- func ContainsRefs(v any) bool
- func Copy(x any) any
- func HasInternedIntNumberTerm(i int) bool
- func IsComprehension(x Value) bool
- func IsConstant(v Value) bool
- func IsError(code string, err error) bool
- func IsFutureKeyword(s string) bool
- func IsInKeywords(s string, keywords []string) bool
- func IsKeyword(s string) bool
- func IsKeywordInRegoVersion(s string, regoVersion RegoVersion) bool
- func IsScalar(v Value) bool
- func IsUnknownValueErr(err error) bool
- func IsValidImportPath(v Value) (err error)
- func IsVarCompatibleString(s string) bool
- func JSON(v Value) (any, error)
- func JSONWithOpt(v Value, opt JSONOpt) (any, error)
- func KeywordsForRegoVersion(v RegoVersion) []string
- func LoadCapabilitiesVersions() ([]string, error)
- func MustJSON(v Value) any
- func ParseStatements(filename, input string) ([]Statement, []*Comment, error)
- func ParseStatementsWithOpts(filename, input string, popts ParserOptions) ([]Statement, []*Comment, error)
- func Pretty(w io.Writer, x any)
- func RegisterBuiltin(b *Builtin)
- func Transform(t Transformer, x any) (any, error)
- func TransformComprehensions(x any, f func(any) (Value, error)) (any, error)
- func TransformRefs(x any, f func(Ref) (Value, error)) (any, error)
- func TransformVars(x any, f func(Var) (Value, error)) (any, error)
- func TypeName(x any) string
- func ValueToInterface(v Value, resolver Resolver) (any, error)
- func Walk(v Visitor, x any)deprecated
- func WalkBeforeAndAfter(v BeforeAndAfterVisitor, x any)deprecated
- func WalkBodies(x any, f func(Body) bool)
- func WalkClosures(x any, f func(any) bool)
- func WalkExprs(x any, f func(*Expr) bool)
- func WalkNodes(x any, f func(Node) bool)
- func WalkRefs(x any, f func(Ref) bool)
- func WalkRules(x any, f func(*Rule) bool)
- func WalkTerms(x any, f func(*Term) bool)
- func WalkVars(x any, f func(Var) bool)
- func WalkWiths(x any, f func(*With) bool)
- type AnnotationSet
- type Annotations
- type AnnotationsRef
- type AnnotationsRefSet
- type Args
- type Array
- type ArrayComprehension
- type AuthorAnnotation
- type BeforeAfterVisitor
- type BeforeAndAfterVisitordeprecated
- type Body
- type Boolean
- type Builtin
- type Call
- type Capabilities
- type Comment
- type CompileOpts
- type Compiler
- func CompileModules(modules map[string]string) (*Compiler, error)
- func CompileModulesWithOpt(modules map[string]string, opts CompileOpts) (*Compiler, error)
- func MustCompileModules(modules map[string]string) *Compiler
- func MustCompileModulesWithOpts(modules map[string]string, opts CompileOpts) *Compiler
- func NewCompiler() *Compiler
- type CompilerEvalMode
- type CompilerStage
- type CompilerStageDefinition
- type ComprehensionIndex
- type DocKind
- type Error
- type ErrorDetails
- type Errors
- type Every
- type Expr
- type FlatAnnotationsRefSet
- type GenericTransformer
- type GenericVisitor
- type Graph
- type GraphTraversal
- type Head
- type Import
- type IndexResult
- type JSONOpt
- type Location
- type Module
- type ModuleLoader
- type ModuleTreeNode
- type Node
- type Null
- type Number
- type Object
- type ObjectComprehension
- type ObjectKeysIterator
- type Package
- type Parser
- type ParserErrorDetail
- type ParserOptions
- type QueryCompiler
- type QueryCompilerStage
- type QueryCompilerStageDefinition
- type QueryContext
- type QueryIterator
- type Ref
- type RefErrInvalidDetail
- type RefErrUnsupportedDetail
- type RegoVersion
- type RelatedResourceAnnotation
- type Resolver
- type Rule
- func MustParseRule(input string) *Rule
- func MustParseRuleWithOpts(input string, opts ParserOptions) *Rule
- func ParseCompleteDocRuleFromAssignmentExpr(module *Module, lhs, rhs *Term) (*Rule, error)
- func ParseCompleteDocRuleFromEqExpr(module *Module, lhs, rhs *Term) (*Rule, error)
- func ParseCompleteDocRuleWithDotsFromTerm(module *Module, term *Term) (*Rule, error)
- func ParsePartialObjectDocRuleFromEqExpr(module *Module, lhs, rhs *Term) (*Rule, error)
- func ParsePartialSetDocRuleFromTerm(module *Module, term *Term) (*Rule, error)
- func ParseRule(input string) (*Rule, error)
- func ParseRuleFromBody(module *Module, body Body) (*Rule, error)
- func ParseRuleFromCallEqExpr(module *Module, lhs, rhs *Term) (*Rule, error)
- func ParseRuleFromCallExpr(module *Module, terms []*Term) (*Rule, error)
- func ParseRuleFromExpr(module *Module, expr *Expr) (*Rule, error)
- func ParseRuleWithOpts(input string, opts ParserOptions) (*Rule, error)
- type RuleIndex
- type RuleKind
- type RuleSet
- type RulesOptions
- type SchemaAnnotation
- type SchemaSet
- type Set
- type SetComprehension
- type SomeDecl
- type Statement
- func MustParseStatement(input string) Statement
- func MustParseStatementWithOpts(input string, popts ParserOptions) Statement
- func MustParseStatements(input string) []Statement
- func ParseStatement(input string) (Statement, error)
- func ParseStatementWithOpts(input string, popts ParserOptions) (Statement, error)
- type String
- type Term
- func ArrayComprehensionTerm(term *Term, body Body) *Term
- func ArrayTerm(a ...*Term) *Term
- func BooleanTerm(b bool) *Term
- func CallTerm(terms ...*Term) *Term
- func FloatNumberTerm(f float64) *Term
- func IntNumberTerm(i int) *Term
- func InternedBooleanTerm(b bool) *Term
- func InternedIntNumberTerm(i int) *Term
- func Item(key, value *Term) [2]*Term
- func MustParseTerm(input string) *Term
- func NewTerm(v Value) *Term
- func NullTerm() *Term
- func NumberTerm(n json.Number) *Term
- func ObjectComprehensionTerm(key, value *Term, body Body) *Term
- func ObjectTerm(o ...[2]*Term) *Term
- func ParseTerm(input string) (*Term, error)
- func RefTerm(r ...*Term) *Term
- func SetComprehensionTerm(term *Term, body Body) *Term
- func SetTerm(t ...*Term) *Term
- func StringTerm(s string) *Term
- func UIntNumberTerm(u uint64) *Term
- func VarTerm(v string) *Term
- type Transformer
- type TreeNode
- type TypeEnv
- type UnificationErrDetail
- type UnknownValueErr
- type Value
- type ValueMap
- type ValueResolver
- type Var
- type VarSet
- type VarVisitor
- type VarVisitorParams
- type VersionIndex
- type Visitordeprecated
- type WasmABIVersion
- type With
Constants¶
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)
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)
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)
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)
const (SingleValue =v1.SingleValueMultiValue =v1.MultiValue)
const CompileErrorLimitDefault = 10CompileErrorLimitDefault is the default number errors a compiler will allow beforeexiting.
const DefaultRegoVersion =RegoV0const FeatureRefHeadStringPrefixes =v1.FeatureRefHeadStringPrefixesIn 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.
const FeatureRefHeads =v1.FeatureRefHeadsconst FeatureRegoV1 =v1.FeatureRegoV1const FeatureRegoV1Import =v1.FeatureRegoV1Importconst SystemDocumentKey =v1.SystemDocumentKeySystemDocumentKey is the name of the top-level key that identifies the systemdocument.
const WildcardPrefix =v1.WildcardPrefixWildcardPrefix is the special character that all wildcard variables areprefixed with when the statement they are contained in is parsed.
Variables¶
var Abs =v1.Absvar AddDate =v1.AddDatevar All =v1.AllAll takes a list and returns true if all of the itemsare true. A collection of length 0 returns true.
var And =v1.Andvar Any =v1.AnyAny takes a collection and returns true if any of the itemsis true. A collection of length 0 returns false.
var AnyPrefixMatch =v1.AnyPrefixMatchvar AnySuffixMatch =v1.AnySuffixMatchvar ArrayConcat =v1.ArrayConcatvar ArrayReverse =v1.ArrayReversevar ArraySlice =v1.ArraySlicevar Assign =v1.AssignAssign represents the assignment (":=") operator.
var Base64Decode =v1.Base64Decodevar Base64Encode =v1.Base64Encodevar Base64IsValid =v1.Base64IsValidvar Base64UrlDecode =v1.Base64UrlDecodevar Base64UrlEncode =v1.Base64UrlEncodevar Base64UrlEncodeNoPad =v1.Base64UrlEncodeNoPadvar BitsAnd =v1.BitsAndvar BitsNegate =v1.BitsNegatevar BitsOr =v1.BitsOrvar BitsShiftLeft =v1.BitsShiftLeftvar BitsShiftRight =v1.BitsShiftRightvar BitsXOr =v1.BitsXOrvar BuiltinMap =v1.BuiltinMapBuiltinMap provides a convenient mapping of built-in names tobuilt-in definitions.
var Builtins =v1.BuiltinsBuiltins is the registry of built-in functions supported by OPA.Call RegisterBuiltin to add a new built-in.
var CastArray =v1.CastArrayCastArray 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.
var CastBoolean =v1.CastBooleanCastBoolean returns input if it is a boolean; if not returns error.
var CastNull =v1.CastNullCastNull returns null if input is null; if not returns error.
var CastObject =v1.CastObjectCastObject returns the given object if it is null; throws an error otherwise
var CastSet =v1.CastSetCastSet 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
var CastString =v1.CastStringCastString returns input if it is a string; if not returns error.For formatting variables, see sprintf
var Ceil =v1.Ceilvar Clock =v1.Clockvar Concat =v1.Concatvar Contains =v1.Containsvar Count =v1.Countvar CryptoHmacEqual =v1.CryptoHmacEqualvar CryptoHmacMd5 =v1.CryptoHmacMd5var CryptoHmacSha1 =v1.CryptoHmacSha1var CryptoHmacSha256 =v1.CryptoHmacSha256var CryptoHmacSha512 =v1.CryptoHmacSha512var CryptoMd5 =v1.CryptoMd5var CryptoParsePrivateKeys =v1.CryptoParsePrivateKeysvar CryptoSha1 =v1.CryptoSha1var CryptoSha256 =v1.CryptoSha256var CryptoX509ParseAndVerifyCertificates =v1.CryptoX509ParseAndVerifyCertificatesvar CryptoX509ParseAndVerifyCertificatesWithOptions =v1.CryptoX509ParseAndVerifyCertificatesWithOptionsvar CryptoX509ParseCertificateRequest =v1.CryptoX509ParseCertificateRequestvar CryptoX509ParseCertificates =v1.CryptoX509ParseCertificatesvar CryptoX509ParseKeyPair =v1.CryptoX509ParseKeyPairvar CryptoX509ParseRSAPrivateKey =v1.CryptoX509ParseRSAPrivateKeyvar Date =v1.Datevar DefaultBuiltins =v1.DefaultBuiltinsDefaultBuiltins is the registry of built-in functions supported in OPAby default. When adding a new built-in function to OPA, update thislist.
var DefaultRootDocument =v1.DefaultRootDocumentDefaultRootDocument is the default root document.
All package directives inside source files are implicitly prefixed with theDefaultRootDocument value.
var DefaultRootRef =v1.DefaultRootRefDefaultRootRef 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.
var Diff =v1.Diffvar Divide =v1.Dividevar EndsWith =v1.EndsWithvar Equal =v1.EqualEqual represents the "==" comparison operator.
var Equality =v1.EqualityEquality represents the "=" operator.
var Floor =v1.Floorvar Format =v1.Formatvar FormatInt =v1.FormatIntvar FunctionArgRootDocument =v1.FunctionArgRootDocumentFunctionArgRootDocument names the document containing function arguments.It's only for internal usage, for referencing function arguments betweenthe index and topdown.
var FutureRootDocument =v1.FutureRootDocumentFutureRootDocument names the document containing new, to-become-default,features.
var GlobMatch =v1.GlobMatchvar GlobQuoteMeta =v1.GlobQuoteMetavar GlobsMatch =v1.GlobsMatchGlobsMatch 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.
var GraphQLIsValid =v1.GraphQLIsValidGraphQLIsValid returns true if a GraphQL query is valid with a givenschema, and returns false for all other inputs.
var GraphQLParse =v1.GraphQLParseGraphQLParse returns a pair of AST objects from parsing/validation.
var GraphQLParseAndVerify =v1.GraphQLParseAndVerifyGraphQLParseAndVerify returns a boolean and a pair of AST object from parsing/validation.
var GraphQLParseQuery =v1.GraphQLParseQueryGraphQLParseQuery parses the input GraphQL query and returns a JSONrepresentation of its AST.
var GraphQLParseSchema =v1.GraphQLParseSchemaGraphQLParseSchema parses the input GraphQL schema and returns a JSONrepresentation of its AST.
var GraphQLSchemaIsValid =v1.GraphQLSchemaIsValidGraphQLSchemaIsValid returns true if the input is valid GraphQL schema,and returns false for all other inputs.
var GreaterThan =v1.GreaterThanvar GreaterThanEq =v1.GreaterThanEqvar HTTPSend =v1.HTTPSendMarked non-deterministic because HTTP request results can be non-deterministic.
var HexDecode =v1.HexDecodevar HexEncode =v1.HexEncodevar IgnoreDuringPartialEval =v1.IgnoreDuringPartialEvalDeprecated: Builtins can now be directly annotated with theNondeterministic property, and when set to true, will be ignoredfor partial evaluation.
var IndexOf =v1.IndexOfvar IndexOfN =v1.IndexOfNvar InputRootDocument =v1.InputRootDocumentInputRootDocument names the document containing query arguments.
var InputRootRef =v1.InputRootRefInputRootRef is a reference to the root of the input document.
All refs to query arguments are prefixed with this ref.
var InternalPrint =v1.InternalPrintInternalPrint represents the internal implementation of the print() function.The compiler rewrites print() calls to refer to the internal implementation.
var Intersection =v1.Intersectionvar IsArray =v1.IsArrayvar IsBoolean =v1.IsBooleanvar IsNull =v1.IsNullvar IsNumber =v1.IsNumbervar IsObject =v1.IsObjectvar IsSet =v1.IsSetvar IsString =v1.IsStringvar JSONFilter =v1.JSONFiltervar JSONIsValid =v1.JSONIsValidvar JSONMarshal =v1.JSONMarshalvar JSONMarshalWithOptions =v1.JSONMarshalWithOptionsvar JSONMatchSchema =v1.JSONMatchSchemaJSONMatchSchema returns empty array if the document matches the JSON schema,and returns non-empty array with error objects otherwise.
var JSONPatch =v1.JSONPatchvar JSONRemove =v1.JSONRemovevar JSONSchemaVerify =v1.JSONSchemaVerifyJSONSchemaVerify returns empty string if the input is valid JSON schemaand returns error string for all other inputs.
var JSONUnmarshal =v1.JSONUnmarshalvar JWTDecode =v1.JWTDecodevar JWTDecodeVerify =v1.JWTDecodeVerifyMarked non-deterministic because it relies on time internally.
var JWTEncodeSign =v1.JWTEncodeSignMarked non-deterministic because it relies on RNG internally.
var JWTEncodeSignRaw =v1.JWTEncodeSignRawMarked non-deterministic because it relies on RNG internally.
var JWTVerifyES256 =v1.JWTVerifyES256var JWTVerifyES384 =v1.JWTVerifyES384var JWTVerifyES512 =v1.JWTVerifyES512var JWTVerifyHS256 =v1.JWTVerifyHS256var JWTVerifyHS384 =v1.JWTVerifyHS384var JWTVerifyHS512 =v1.JWTVerifyHS512var JWTVerifyPS256 =v1.JWTVerifyPS256var JWTVerifyPS384 =v1.JWTVerifyPS384var JWTVerifyPS512 =v1.JWTVerifyPS512var JWTVerifyRS256 =v1.JWTVerifyRS256var JWTVerifyRS384 =v1.JWTVerifyRS384var JWTVerifyRS512 =v1.JWTVerifyRS512var Keywords =v1.KeywordsKeywords contains strings that map to language keywords.
var KeywordsV0 =v1.KeywordsV0var KeywordsV1 =v1.KeywordsV1var LessThan =v1.LessThanLessThan represents the "<" comparison operator.
var LessThanEq =v1.LessThanEqvar Lower =v1.Lowervar Max =v1.Maxvar Member =v1.MemberMember represents the `in` (infix) operator.
var MemberWithKey =v1.MemberWithKeyMemberWithKey represents the `in` (infix) operator when usedwith two terms on the lhs, i.e., `k, v in obj`.
var Min =v1.Minvar Minus =v1.Minusvar Multiply =v1.Multiplyvar NetCIDRContains =v1.NetCIDRContainsvar NetCIDRContainsMatches =v1.NetCIDRContainsMatchesvar NetCIDRExpand =v1.NetCIDRExpandvar NetCIDRIntersects =v1.NetCIDRIntersectsvar NetCIDRIsValid =v1.NetCIDRIsValidvar NetCIDRMerge =v1.NetCIDRMergevar NetCIDROverlap =v1.NetCIDROverlapNetCIDROverlap has been replaced by the `net.cidr_contains` built-in.
var NetLookupIPAddr =v1.NetLookupIPAddrMarked non-deterministic because DNS resolution results can be non-deterministic.
var NotEqual =v1.NotEqualvar NowNanos =v1.NowNanosMarked non-deterministic because it relies on time directly.
var NumbersRange =v1.NumbersRangevar NumbersRangeStep =v1.NumbersRangeStepvar OPARuntime =v1.OPARuntimeMarked non-deterministic because of unpredictable config/environment-dependent results.
var ObjectFilter =v1.ObjectFiltervar ObjectGet =v1.ObjectGetvar ObjectKeys =v1.ObjectKeysvar ObjectRemove =v1.ObjectRemovevar ObjectSubset =v1.ObjectSubsetvar ObjectUnion =v1.ObjectUnionvar ObjectUnionN =v1.ObjectUnionNvar Or =v1.OrOr performs a union operation on sets.
var ParseDurationNanos =v1.ParseDurationNanosvar ParseNanos =v1.ParseNanosvar ParseRFC3339Nanos =v1.ParseRFC3339Nanosvar Plus =v1.Plusvar Print =v1.PrintPrint 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.
var Product =v1.Productvar ProvidersAWSSignReqObj =v1.ProvidersAWSSignReqObjvar RandIntn =v1.RandIntnRandIntn returns a random number 0 - nMarked non-deterministic because it relies on RNG internally.
var ReachableBuiltin =v1.ReachableBuiltinvar ReachablePathsBuiltin =v1.ReachablePathsBuiltinvar RegexFind =v1.RegexFindRegexFind takes two strings and a number, the pattern, the value and number of match values toreturn, -1 means all match values.
var RegexFindAllStringSubmatch =v1.RegexFindAllStringSubmatchvar RegexIsValid =v1.RegexIsValidvar RegexMatch =v1.RegexMatchvar RegexMatchDeprecated =v1.RegexMatchDeprecatedRegexMatchDeprecated declares `re_match` which has been deprecated. Use `regex.match` instead.
var RegexReplace =v1.RegexReplacevar RegexSplit =v1.RegexSplitvar RegexTemplateMatch =v1.RegexTemplateMatchvar RegoMetadataChain =v1.RegoMetadataChainvar RegoMetadataRule =v1.RegoMetadataRuleRegoMetadataRule returns the metadata for the active rule
var RegoParseModule =v1.RegoParseModulevar RegoRootDocument =v1.RegoRootDocumentRegoRootDocument names the document containing new, to-become-default,features in a future versioned release.
var RegoV1CompatibleRef =v1.RegoV1CompatibleRefvar Rem =v1.Remvar RenderTemplate =v1.RenderTemplatevar Replace =v1.Replacevar ReplaceN =v1.ReplaceNvar ReservedVars =v1.ReservedVarsReservedVars is the set of names that refer to implicitly ground vars.
var RootDocumentNames =v1.RootDocumentNamesRootDocumentNames 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).
var RootDocumentRefs =v1.RootDocumentRefsRootDocumentRefs contains the prefixes of top-level documents that allnon-local references start with.
var Round =v1.Roundvar SafetyCheckVisitorParams =v1.SafetyCheckVisitorParamsSafetyCheckVisitorParams 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.
var SchemaRootDocument =v1.SchemaRootDocumentSchemaRootDocument names the document containing external data schemas.
var SchemaRootRef =v1.SchemaRootRefSchemaRootRef 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).
var SemVerCompare =v1.SemVerComparevar SemVerIsValid =v1.SemVerIsValidvar SetDiff =v1.SetDiffSetDiff has been replaced by the minus built-in.
var Sort =v1.Sortvar Split =v1.Splitvar Sprintf =v1.Sprintfvar StartsWith =v1.StartsWithvar StringCount =v1.StringCountvar StringReverse =v1.StringReversevar Substring =v1.Substringvar Sum =v1.Sumvar ToNumber =v1.ToNumbervar Trace =v1.Tracevar Trim =v1.Trimvar TrimLeft =v1.TrimLeftvar TrimPrefix =v1.TrimPrefixvar TrimRight =v1.TrimRightvar TrimSpace =v1.TrimSpacevar TrimSuffix =v1.TrimSuffixvar TypeNameBuiltin =v1.TypeNameBuiltinTypeNameBuiltin returns the type of the input.
var URLQueryDecode =v1.URLQueryDecodevar URLQueryDecodeObject =v1.URLQueryDecodeObjectvar URLQueryEncode =v1.URLQueryEncodevar URLQueryEncodeObject =v1.URLQueryEncodeObjectvar UUIDParse =v1.UUIDParsevar UUIDRFC4122 =v1.UUIDRFC4122UUIDRFC4122 returns a version 4 UUID string.Marked non-deterministic because it relies on RNG internally.
var Union =v1.Unionvar UnitsParse =v1.UnitsParsevar UnitsParseBytes =v1.UnitsParseBytesvar Upper =v1.Uppervar WalkBuiltin =v1.WalkBuiltinvar Weekday =v1.Weekdayvar Wildcard =v1.WildcardWildcard represents the wildcard variable as defined in the language.
var YAMLIsValid =v1.YAMLIsValidYAMLIsValid verifies the input string is a valid YAML document.
var YAMLMarshal =v1.YAMLMarshalvar YAMLUnmarshal =v1.YAMLUnmarshalFunctions¶
funcBuildAnnotationSet¶added inv0.38.0
func BuildAnnotationSet(modules []*Module) (*AnnotationSet,Errors)
funcCompare¶added inv0.2.0
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.
funcContainsClosures¶added inv0.37.0
ContainsClosures returns true if the Value v contains closures.
funcContainsComprehensions¶added inv0.5.8
ContainsComprehensions returns true if the Value v contains comprehensions.
funcContainsRefs¶added inv0.5.8
ContainsRefs returns true if the Value v contains refs.
funcCopy¶added inv0.20.5
Copy returns a deep copy of the AST node x. If x is not an AST node, x is returned unmodified.
funcHasInternedIntNumberTerm¶added inv1.0.0
funcIsComprehension¶added inv0.5.11
IsComprehension returns true if the supplied value is a comprehension.
funcIsConstant¶added inv0.4.9
IsConstant returns true if the AST value is constant.
funcIsFutureKeyword¶added inv0.64.0
funcIsInKeywords¶added inv0.69.0
funcIsKeywordInRegoVersion¶added inv0.67.0
func IsKeywordInRegoVersion(sstring, regoVersionRegoVersion)bool
IsKeywordInRegoVersion returns true if s is a language keyword.
funcIsUnknownValueErr¶added inv0.9.0
IsUnknownValueErr returns true if the err is an UnknownValueErr.
funcIsValidImportPath¶added inv0.3.0
IsValidImportPath returns an error indicating if the import path is invalid.If the import path is valid, err is nil.
funcIsVarCompatibleString¶added inv0.58.0
funcJSON¶added inv0.4.9
JSON returns the JSON representation of v. The value must not contain anyrefs or terms that require evaluation (e.g., vars, comprehensions, etc.)
funcJSONWithOpt¶added inv0.27.1
JSONWithOpt returns the JSON representation of v. The value must not contain anyrefs or terms that require evaluation (e.g., vars, comprehensions, etc.)
funcKeywordsForRegoVersion¶added inv0.69.0
func KeywordsForRegoVersion(vRegoVersion) []string
funcLoadCapabilitiesVersions¶added inv0.40.0
LoadCapabilitiesVersions loads all capabilities versions
funcMustJSON¶added inv0.25.0
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¶
ParseStatements is deprecated. Use ParseStatementWithOpts instead.
funcParseStatementsWithOpts¶added 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.
funcPretty¶added inv0.7.0
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.
funcTransform¶added 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.
funcTransformComprehensions¶added inv0.5.8
TransformComprehensions calls the functio nf on all comprehensions under x.
funcTransformRefs¶added inv0.2.0
TransformRefs calls the function f on all references under x.
funcTransformVars¶added inv0.7.0
TransformVars calls the function f on all vars under x.
funcValueToInterface¶added inv0.4.9
ValueToInterface returns the Go representation of an AST value. The ASTvalue should not contain any values that require evaluation (e.g., vars,comprehensions, etc.)
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
funcWalkBodies¶added inv0.2.0
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¶
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.
funcWalkExprs¶added inv0.4.9
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.
funcWalkNodes¶added inv0.9.2
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¶
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.
funcWalkRules¶added inv0.4.10
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.
funcWalkTerms¶added inv0.7.0
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.
Types¶
typeAnnotationSet¶added inv0.38.0
type AnnotationSet =v1.AnnotationSet
typeAnnotations¶added inv0.28.0
type Annotations =v1.Annotations
Annotations represents metadata attached to other AST nodes such as rules.
typeAnnotationsRef¶added inv0.38.0
type AnnotationsRef =v1.AnnotationsRef
funcNewAnnotationsRef¶added inv0.40.0
func NewAnnotationsRef(a *Annotations) *AnnotationsRef
typeAnnotationsRefSet¶added inv0.49.0
type AnnotationsRefSet =v1.AnnotationsRefSet
typeArray¶
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.
typeArrayComprehension¶
type ArrayComprehension =v1.ArrayComprehension
ArrayComprehension represents an array comprehension as defined in the language.
typeAuthorAnnotation¶added inv0.38.0
type AuthorAnnotation =v1.AuthorAnnotation
typeBeforeAfterVisitor¶added 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.
funcNewBeforeAfterVisitor¶added 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¶
Body represents one or more expressions contained inside a rule or userfunction.
funcMustParseBody¶
MustParseBody returns a parsed body.If an error occurs during parsing, panic.
funcMustParseBodyWithOpts¶added inv0.37.0
func MustParseBodyWithOpts(inputstring, optsParserOptions)Body
MustParseBodyWithOpts returns a parsed body.If an error occurs during parsing, panic.
funcNewBody¶added inv0.2.0
NewBody returns a new Body containing the given expressions. The indices ofthe immediate expressions will be reset.
funcParseBody¶
ParseBody returns exactly one body.If multiple bodies are parsed, an error is returned.
funcParseBodyWithOpts¶added 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.
typeBuiltin¶
Builtin represents a built-in function supported by OPA. Every built-infunction is uniquely identified by a name.
typeCapabilities¶added 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.
funcCapabilitiesForThisVersion¶added inv0.23.0
func CapabilitiesForThisVersion() *Capabilities
CapabilitiesForThisVersion returns the capabilities of this version of OPA.
funcLoadCapabilitiesFile¶added inv0.40.0
func LoadCapabilitiesFile(filestring) (*Capabilities,error)
LoadCapabilitiesFile loads a JSON serialized capabilities structure from a file.
funcLoadCapabilitiesJSON¶added inv0.23.0
func LoadCapabilitiesJSON(rio.Reader) (*Capabilities,error)
LoadCapabilitiesJSON loads a JSON serialized capabilities structure from the reader r.
funcLoadCapabilitiesVersion¶added inv0.40.0
func LoadCapabilitiesVersion(versionstring) (*Capabilities,error)
LoadCapabilitiesVersion loads a JSON serialized capabilities structure from the specific version.
typeComment¶added inv0.4.0
Comment contains the raw text from the comment in the definition.
funcNewComment¶added inv0.4.0
NewComment returns a new Comment object.
typeCompileOpts¶added inv0.34.0
type CompileOpts =v1.CompileOpts
CompileOpts defines a set of options for the compiler.
typeCompiler¶
Compiler contains the state of a compilation process.
funcCompileModules¶added inv0.10.2
CompileModules takes a set of Rego modules represented as strings andcompiles them for evaluation. The keys of the map are used as filenames.
funcCompileModulesWithOpt¶added 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.
funcMustCompileModules¶added inv0.10.2
MustCompileModules compiles a set of Rego modules represented as strings. Ifthe compilation process fails, this function panics.
funcMustCompileModulesWithOpts¶added 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.
typeCompilerEvalMode¶added 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.
typeCompilerStage¶added inv0.10.6
type CompilerStage =v1.CompilerStage
CompilerStage defines the interface for stages in the compiler.
typeCompilerStageDefinition¶added inv0.11.0
type CompilerStageDefinition =v1.CompilerStageDefinition
CompilerStageDefinition defines a compiler stage
typeComprehensionIndex¶added 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.)
typeErrorDetails¶added inv0.4.9
type ErrorDetails =v1.ErrorDetails
ErrorDetails defines the interface for detailed error messages.
typeErrors¶added inv0.2.0
Errors represents a series of errors encountered during parsing, compiling,etc.
typeExpr¶
Expr represents a single expression contained inside the body of a rule.
funcMustParseExpr¶added inv0.2.0
MustParseExpr returns a parsed expression.If an error occurs during parsing, panic.
funcNewBuiltinExpr¶
NewBuiltinExpr creates a new Expr object with the supplied terms.The builtin operator must be the first term.
typeFlatAnnotationsRefSet¶added inv0.49.0
type FlatAnnotationsRefSet =v1.FlatAnnotationsRefSet
typeGenericTransformer¶added inv0.2.0
type GenericTransformer =v1.GenericTransformer
GenericTransformer implements the Transformer interface to provide a utilityto transform AST nodes using a closure.
funcNewGenericTransformer¶added 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.
funcNewGenericVisitor¶added inv0.4.1
func NewGenericVisitor(f func(xany)bool) *GenericVisitor
NewGenericVisitor returns a new GenericVisitor that will invoke the functionf on AST nodes.
typeGraphTraversal¶added inv0.12.0
type GraphTraversal =v1.GraphTraversal
GraphTraversal is a Traversal that understands the dependency graph
funcNewGraphTraversal¶added inv0.12.0
func NewGraphTraversal(graph *Graph) *GraphTraversal
NewGraphTraversal returns a Traversal for the dependency graph
typeHead¶added inv0.2.0
Head represents the head of a rule.
funcNewHead¶added inv0.4.1
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.
typeImport¶
Import represents a dependency on a document outside of the policynamespace. Imports are optional.
funcMustParseImports¶added inv0.2.2
MustParseImports returns a slice of imports.If an error occurs during parsing, panic.
funcParseImports¶added inv0.2.2
ParseImports returns a slice of Import objects.
typeIndexResult¶added inv0.4.10
type IndexResult =v1.IndexResult
IndexResult contains the result of an index lookup.
funcNewIndexResult¶added inv0.4.10
func NewIndexResult(kindRuleKind) *IndexResult
NewIndexResult returns a new IndexResult object.
typeModule¶
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¶
MustParseModule returns a parsed module.If an error occurs during parsing, panic.
funcMustParseModuleWithOpts¶added inv0.37.0
func MustParseModuleWithOpts(inputstring, optsParserOptions) *Module
MustParseModuleWithOpts returns a parsed module.If an error occurs during parsing, panic.
funcParseModule¶
ParseModule returns a parsed Module object.For details on Module objects and their fields, see policy.go.Empty input will return nil, nil.
funcParseModuleWithOpts¶added 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.
typeModuleLoader¶added 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.
typeNode¶added inv0.9.2
Node represents a node in an AST. Nodes may be statements in a policy moduleor elements of an ad-hoc query, expression, etc.
typeObjectComprehension¶added inv0.5.2
type ObjectComprehension =v1.ObjectComprehension
ObjectComprehension represents an object comprehension as defined in the language.
typeObjectKeysIterator¶added 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¶
Package represents the namespace of the documents producedby rules inside the module.
funcMustParsePackage¶added inv0.2.2
MustParsePackage returns a Package.If an error occurs during parsing, panic.
funcParsePackage¶added inv0.2.2
ParsePackage returns exactly one Package.If multiple statements are parsed, an error is returned.
typeParserErrorDetail¶added inv0.15.0
type ParserErrorDetail =v1.ParserErrorDetail
ParserErrorDetail holds additional details for parser errors.
typeParserOptions¶added inv0.28.0
type ParserOptions =v1.ParserOptions
ParserOptions defines the options for parsing Rego statements.
typeQueryCompiler¶added inv0.2.2
type QueryCompiler =v1.QueryCompiler
QueryCompiler defines the interface for compiling ad-hoc queries.
typeQueryCompilerStage¶added inv0.7.0
type QueryCompilerStage =v1.QueryCompilerStage
QueryCompilerStage defines the interface for stages in the query compiler.
typeQueryCompilerStageDefinition¶added inv0.11.0
type QueryCompilerStageDefinition =v1.QueryCompilerStageDefinition
QueryCompilerStageDefinition defines a QueryCompiler stage
typeQueryContext¶added 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.
funcNewQueryContext¶added 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¶
Ref represents a reference as defined by the language.
funcMustParseRef¶
MustParseRef returns a parsed reference.If an error occurs during parsing, panic.
typeRefErrInvalidDetail¶added 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.)
typeRefErrUnsupportedDetail¶added inv0.5.2
type RefErrUnsupportedDetail =v1.RefErrUnsupportedDetail
RefErrUnsupportedDetail describes an undefined reference error where thereferenced value does not support dereferencing (e.g., scalars).
typeRegoVersion¶added inv0.60.0
type RegoVersion =v1.RegoVersion
RegoVersion defines the Rego syntax requirements for a module.
funcRegoVersionFromInt¶added inv0.64.0
func RegoVersionFromInt(iint)RegoVersion
typeRelatedResourceAnnotation¶added inv0.38.0
type RelatedResourceAnnotation =v1.RelatedResourceAnnotation
typeResolver¶added inv0.4.9
Resolver defines the interface for resolving references to native Go values.
typeRule¶
Rule represents a rule as defined in the language. Rules define thecontent of documents that represent policy decisions.
funcMustParseRule¶
MustParseRule returns a parsed rule.If an error occurs during parsing, panic.
funcMustParseRuleWithOpts¶added inv0.69.0
func MustParseRuleWithOpts(inputstring, optsParserOptions) *Rule
MustParseRuleWithOpts returns a parsed rule.If an error occurs during parsing, panic.
funcParseCompleteDocRuleFromAssignmentExpr¶added inv0.14.0
ParseCompleteDocRuleFromAssignmentExpr returns a rule if the expression canbe interpreted as a complete document definition declared with the assignmentoperator.
funcParseCompleteDocRuleFromEqExpr¶added inv0.5.6
ParseCompleteDocRuleFromEqExpr returns a rule if the expression can beinterpreted as a complete document definition.
funcParseCompleteDocRuleWithDotsFromTerm¶added inv0.46.0
funcParsePartialObjectDocRuleFromEqExpr¶added inv0.5.6
ParsePartialObjectDocRuleFromEqExpr returns a rule if the expression can beinterpreted as a partial object document definition.
funcParsePartialSetDocRuleFromTerm¶added inv0.5.6
ParsePartialSetDocRuleFromTerm returns a rule if the term can be interpretedas a partial set document definition.
funcParseRule¶
ParseRule returns exactly one rule.If multiple rules are parsed, an error is returned.
funcParseRuleFromBody¶added inv0.3.0
ParseRuleFromBody returns a rule if the body can be interpreted as a ruledefinition. Otherwise, an error is returned.
funcParseRuleFromCallEqExpr¶added inv0.7.0
ParseRuleFromCallEqExpr returns a rule if the term can be interpreted as afunction definition (e.g., f(x) = y => f(x) = y { true }).
funcParseRuleFromCallExpr¶added inv0.5.9
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 }).
funcParseRuleFromExpr¶added inv0.5.6
ParseRuleFromExpr returns a rule if the expression can be interpreted as arule definition.
funcParseRuleWithOpts¶added inv0.46.0
func ParseRuleWithOpts(inputstring, optsParserOptions) (*Rule,error)
ParseRuleWithOpts returns exactly one rule.If multiple rules are parsed, an error is returned.
typeRuleSet¶added inv0.4.9
RuleSet represents a collection of rules that produce a virtual document.
funcNewRuleSet¶added inv0.4.9
NewRuleSet returns a new RuleSet containing the given rules.
typeRulesOptions¶added inv0.34.0
type RulesOptions =v1.RulesOptions
RulesOptions defines the options for retrieving rules by Ref from thecompiler.
typeSchemaAnnotation¶added inv0.28.0
type SchemaAnnotation =v1.SchemaAnnotation
SchemaAnnotation contains a schema declaration for the document identified by the path.
typeSchemaSet¶added inv0.27.0
SchemaSet holds a map from a path to a schema.
funcNewSchemaSet¶added inv0.28.0
func NewSchemaSet() *SchemaSet
NewSchemaSet returns an empty SchemaSet.
typeSetComprehension¶added inv0.5.2
type SetComprehension =v1.SetComprehension
SetComprehension represents a set comprehension as defined in the language.
typeSomeDecl¶added inv0.11.0
SomeDecl represents a variable declaration statement. The symbols are variables.
typeStatement¶
Statement represents a single statement in a policy module.
funcMustParseStatement¶
MustParseStatement returns exactly one statement.If an error occurs during parsing, panic.
funcMustParseStatementWithOpts¶added inv0.69.0
func MustParseStatementWithOpts(inputstring, poptsParserOptions)Statement
funcMustParseStatements¶
MustParseStatements returns a slice of parsed statements.If an error occurs during parsing, panic.
funcParseStatement¶
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.
funcParseStatementWithOpts¶added inv0.69.0
func ParseStatementWithOpts(inputstring, poptsParserOptions) (Statement,error)
typeTerm¶
Term is an argument to a function.
funcArrayComprehensionTerm¶
ArrayComprehensionTerm creates a new Term with an ArrayComprehension value.
funcCallTerm¶added inv0.7.0
CallTerm returns a new Term with a Call value defined by terms. The firstterm is the operator and the rest are operands.
funcFloatNumberTerm¶added inv0.3.0
FloatNumberTerm creates a new Term with a floating point Number value.
funcIntNumberTerm¶added inv0.3.0
IntNumberTerm creates a new Term with an integer Number value.
funcInternedBooleanTerm¶added inv1.0.0
funcInternedIntNumberTerm¶added inv1.0.0
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¶
Item is a helper for constructing an tuple containing two Termsrepresenting a key/value pair in an Object.
funcMustParseTerm¶
MustParseTerm returns a parsed term.If an error occurs during parsing, panic.
funcNumberTerm¶
NumberTerm creates a new Term with a Number value.
funcObjectComprehensionTerm¶added inv0.5.2
ObjectComprehensionTerm creates a new Term with an ObjectComprehension value.
funcObjectTerm¶
ObjectTerm creates a new Term with an Object value.
funcParseTerm¶
ParseTerm returns exactly one term.If multiple terms are parsed, an error is returned.
funcSetComprehensionTerm¶added inv0.5.2
SetComprehensionTerm creates a new Term with an SetComprehension value.
funcUIntNumberTerm¶added inv0.22.0
UIntNumberTerm creates a new Term with an unsigned integer Number value.
typeTransformer¶added 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.
typeTreeNode¶added inv0.5.0
TreeNode represents a node in the rule tree. The rule tree is keyed byrule path.
funcNewRuleTree¶added 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.
typeUnificationErrDetail¶added inv0.4.9
type UnificationErrDetail =v1.UnificationErrDetail
UnificationErrDetail describes a type mismatch error when two values areunified (e.g., x = [1,2,y]).
typeUnknownValueErr¶added 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¶
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¶
InterfaceToValue converts a native Go value x to a Value.
funcMustInterfaceToValue¶added inv0.4.5
MustInterfaceToValue converts a native Go value x to a Value. If theconversion fails, this function will panic. This function is mostly for testpurposes.
typeValueMap¶added inv0.2.0
ValueMap represents a key/value map between AST term values. Any type of termcan be used as a key in the map.
typeValueResolver¶added inv0.4.9
type ValueResolver =v1.ValueResolver
ValueResolver defines the interface for resolving references to AST values.
typeVarSet¶
VarSet represents a set of variables.
funcOutputVarsFromBody¶added inv0.20.0
OutputVarsFromBody returns all variables which are the "output" forthe given body. For safety checks this means that they would bemade safe by the body.
funcOutputVarsFromExpr¶added inv0.20.0
OutputVarsFromExpr returns all variables which are the "output" forthe given expression. For safety checks this means that they would bemade safe by the expr.
typeVarVisitor¶added 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.
funcNewVarVisitor¶added inv0.3.0
func NewVarVisitor() *VarVisitor
NewVarVisitor returns a new VarVisitor object.
typeVarVisitorParams¶added inv0.3.0
type VarVisitorParams =v1.VarVisitorParams
VarVisitorParams contains settings for a VarVisitor.
typeVersionIndex¶added 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
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
typeWasmABIVersion¶added inv0.27.0
type WasmABIVersion =v1.WasmABIVersion
WasmABIVersion captures the Wasm ABI version. Its `Minor` version is indicatingbackwards-compatible changes.
Source Files¶
Directories¶
| Path | Synopsis |
|---|---|
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. |