Documentation
¶
Index ¶
- func Module(filename, policy string) (*ast.Module, error)
- func ModuleUnknownVersionWithOpts(filename, policy string, opts ast.ParserOptions) (*ast.Module, error)
- func ModuleWithOpts(path, policy string, opts ast.ParserOptions) (module *ast.Module, err error)
- func MustParseModule(policy string) *ast.Module
- func ParserOptions() ast.ParserOptions
- func PrepareAST(name string, content string, module *ast.Module) (map[string]any, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Module ¶ added in v0.9.0
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
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 ¶
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
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.