Documentation
¶
Index ¶
- func RegoVersionFromVersionsMap(versionsMap map[string]ast.RegoVersion, filename string, ...) ast.RegoVersion
- type Input
- func InputFromMap(files map[string]string, versionsMap map[string]ast.RegoVersion) (Input, error)
- func InputFromPaths(paths []string, prefix string, versionsMap map[string]ast.RegoVersion) (Input, error)
- func InputFromText(fileName, text string) (Input, error)
- func InputFromTextWithOptions(fileName, text string, opts ast.ParserOptions) (Input, error)
- func NewInput(fileContent map[string]string, modules map[string]*ast.Module) Input
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
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
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.