You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/docs/how-to/writing-rules-in-rego.md
+17-7
Original file line number
Diff line number
Diff line change
@@ -30,19 +30,29 @@ Note that these are known patterns in the OPA community, so we’re not doing an
30
30
31
31
Given the context in which Minder operates, we did need to add some custom functionality that OPA doesn’t provide out of the box. Namely, we added the following custom functions:
32
32
33
-
***file.exists**: Verifies that the given file exists in the Git repository.
33
+
***file.exists(filepath)**: Verifies that the given filepath exists in the Git repository, returns a boolean.
34
34
35
-
***file.read**: Reads the contents of the given file in the Git repository.
35
+
***file.read(filepath)**: Reads the contents of the given file in the Git repository and returns the contents as a string.
36
36
37
-
***file.ls**: Lists files in the given directory in the Git repository.
37
+
***file.ls(directory)**: Lists files in the given directory in the Git repository, returning the filenames as an array of strings.
38
38
39
-
***file.ls_glob**: Lists files in the given directory in the Git repository that match the given glob pattern.
39
+
***file.ls_glob(pattern)**: Lists files in the given directory in the Git repository that match the given glob pattern, returning matched filenames as an array of strings.
40
40
41
-
***file.http_type**: Returns the HTTP content type of the given file.
41
+
***file.http_type(filepath)**: Determines the HTTP (MIME) content type of the given file by [examining the first 512 bytes of the file](https://mimesniff.spec.whatwg.org/). It returns the content type as a string.
42
42
43
-
***file.walk**: Walks the given directory in the Git repository and lists all files.
43
+
***file.walk(path)**: Walks the given path (directory or file) in the Git repository and returns a list of paths to all regular files (not directories) as an array of strings.
44
44
45
-
***github_workflow.ls_actions**: Lists all actions in the given GitHub workflow directory.
45
+
***github_workflow.ls_actions(directory)**: Lists all actions in the given GitHub workflow directory, returning the filenames as an array of strings.
46
+
47
+
***parse_yaml**: Parses a YAML string into a JSON object. This implementation uses https://gopkg.in/yaml.v3, which avoids bugs when parsing `"on"` as an object _key_ (for example, in GitHub workflows).
48
+
49
+
***jq.is_true(object, query)**: Evaluates a jq query against the specified object, returning `true` if the query result is a true boolean value, andh `false` otherwise.
50
+
51
+
***file.archive(paths)**: _(experimental)_ Builds a `.tar.gz` format archive containing all files under the given paths. Returns the archive contents as a (binary) string.
52
+
53
+
_(experimental)_ In addition, when operating in a pull request context, `base_file` versions of the `file` operations are available for accessing the files in the base branch of the pull request. The `file` versions of the operations operate on the head (proposed changes) versions of the files in a pull request context.
54
+
55
+
In addition, most of the [standard OPA functions are available in the Minder runtime](https://www.openpolicyagent.org/docs/latest/policy-reference/#built-in-functions).
0 commit comments