parse

package
v0.35.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module added in v0.9.0

func Module(filename, policy string) (*ast.Module, error)

Module works like ast.ParseModule but with the Regal parser options applied. Note that this function will parse using the RegoV1 parser version. If the version of the policy is unknown, use ModuleUnknownVersionWithOpts instead.

func ModuleUnknownVersionWithOpts added in v0.30.0

func ModuleUnknownVersionWithOpts(filename, policy string, opts ast.ParserOptions) (*ast.Module, error)

ModuleUnknownVersionWithOpts attempts to parse a module with an unknown Rego version. The function will attempt to parse the module with different parser versions, and determine the version of Rego based on which parser was successful. Note that this is not 100% accurate, and the conditions for determining the version may change over time. If the version is known beforehand, use ModuleWithOpts instead, and provide the target Rego version in the parser options.

func ModuleWithOpts added in v0.30.0

func ModuleWithOpts(path, policy string, opts ast.ParserOptions) (module *ast.Module, err error)

ModuleWithOpts parses a module with the given options. If the Rego version is unknown, the function may attempt to run several parser versions to determine the correct version. Setting the Rego version in the parser options will skip this step, and is recommended whenever possible.

func MustParseModule

func MustParseModule(policy string) *ast.Module

MustParseModule works like ast.MustParseModule but with the Regal parser options applied.

func ParserOptions

func ParserOptions() ast.ParserOptions

ParserOptions provides parser options with annotation processing. JSONOptions are not included, as it is assumed that the caller will marshal the AST to JSON with the roast encoder rather than encoding/json (and consequently, the OPA marshaller implementations).

func PrepareAST added in v0.14.0

func PrepareAST(name string, content string, module *ast.Module) (map[string]any, error)

PrepareAST prepares the AST to be used as linter input. Deprecated: New code should use the `transform` package from roast, as this avoids an expensive intermediate step in module -> ast.Value conversions.

Types

This section is empty.

Jump to

Keyboard shortcuts

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