rules

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegoVersionFromVersionsMap added in v0.30.1

func RegoVersionFromVersionsMap(
	versionsMap map[string]ast.RegoVersion,
	filename string,
	defaultVersion ast.RegoVersion,
) ast.RegoVersion

RegoVersionFromVersionsMap takes a mapping of file path prefixes, typically representing the roots of the project, and the expected Rego version for each. Using this, it finds the longest matching prefix for the given filename and returns the defaultVersion if to matching prefix is found.

Types

type Input

type Input struct {
	// FileContent carries the string contents of each file
	FileContent map[string]string
	// Modules is the set of modules to lint.
	Modules map[string]*ast.Module
	// FileNames is used to maintain consistent order between runs.
	FileNames []string
}

Input represents the input for a linter evaluation.

func InputFromMap added in v0.30.1

func InputFromMap(files map[string]string, versionsMap map[string]ast.RegoVersion) (Input, error)

InputFromMap creates a new Input from a map of file paths to their contents. This function uses a vesrionsMap to determine the parser version for each file before parsing the module.

func InputFromPaths

func InputFromPaths(paths []string, prefix string, versionsMap map[string]ast.RegoVersion) (Input, error)

InputFromPaths creates a new Input from a set of file or directory paths. Note that this function assumes that the paths point to valid Rego files. Use config.FilterIgnoredPaths to filter out unwanted content *before* calling this function. When the versionsMap is not nil/empty, files in a directory matching a key in the map will be parsed with the corresponding Rego version. If not provided, the file may be parsed multiple times in order to determine the version (best-effort and may include false positives).

func InputFromText added in v0.9.0

func InputFromText(fileName, text string) (Input, error)

InputFromText creates a new Input from raw Rego text.

func InputFromTextWithOptions added in v0.30.0

func InputFromTextWithOptions(fileName, text string, opts ast.ParserOptions) (Input, error)

InputFromTextWithOptions creates a new Input from raw Rego text while respecting the provided options.

func NewInput

func NewInput(fileContent map[string]string, modules map[string]*ast.Module) Input

NewInput creates a new Input from a set of modules.

Jump to

Keyboard shortcuts

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