Skip to content

Commit e85b878

Browse files
author
Charlie Egan
authored
docs: Update config cli docs (#1584)
* docs: Update cli and config documentation Place them in own sections not in readme. #1558 (comment) Signed-off-by: Charlie Egan <charlie@styra.com> * docs: Add community footers Signed-off-by: Charlie Egan <charlie@styra.com> * docs: add more to the next steps Signed-off-by: Charlie Egan <charlie@styra.com> * docs: Correct yaml format And update readme Signed-off-by: Charlie Egan <charlie@styra.com> * docs: Add community footers to new pages Signed-off-by: Charlie Egan <charlie@styra.com> --------- Signed-off-by: Charlie Egan <charlie@styra.com>
1 parent 6f45a9f commit e85b878

52 files changed

Lines changed: 325 additions & 763 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 23 additions & 566 deletions
Large diffs are not rendered by default.

build/update-readme.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ while IFS= read -r file; do
2222
cat "$section_path" >> "$tmpfile"
2323
echo -e "\n" >> "$tmpfile"
2424
else
25-
echo "Warning: Section file not found: $section_path" >&2
25+
echo "Section file not found: $section_path" >&2
26+
exit 1
2627
fi
2728
done < "$MANIFEST"
2829

docs/cicd.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
Its possible to use Regal to lint your Rego policies in your CI/CD pipeline(s)!
44

5-
This document will guide you on how to do so.
5+
This document will guide you on how to do so. Please also review the
6+
[CLI](./cli) documentation for more information on the available options.
67

78
## GitHub Actions
89

@@ -52,3 +53,8 @@ regal_lint_policies:
5253

5354
The above will run Regal on the `policy` directory when a merge request is created or updated and will show linting
5455
violations as part of the merge request.
56+
57+
## Community
58+
59+
For questions, discussions and announcements related to Styra products, services and open source projects, please join
60+
the Styra community on [Slack](https://inviter.co/styra)!

docs/cli.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# CLI
2+
3+
Regal's CLI is the main way to interact with Regal. In order to support
4+
different use cases (Local, CI, etc.) Regal's CLI is designed with a number of
5+
different formats and exit behaviors.
6+
7+
## Output Formats
8+
9+
The `regal lint` command allows specifying the output format by using the `--format` flag. The available output formats
10+
are:
11+
12+
- `pretty` (default) - Human-readable table-like output where each violation is printed with a detailed explanation
13+
- `compact` - Human-readable output where each violation is printed on a single line
14+
- `json` - JSON output, suitable for programmatic consumption
15+
- `github` - GitHub [workflow command](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions)
16+
output, ideal for use in GitHub Actions. Annotates PRs and creates a
17+
[job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary)
18+
from the linter report
19+
- `sarif` - [SARIF](https://sarifweb.azurewebsites.net/) JSON output, for consumption by tools processing code analysis
20+
reports
21+
- `junit` - JUnit XML output, e.g. for CI servers like GitLab that show these results in a merge request.
22+
23+
## Exit Codes
24+
25+
Exit codes are used to indicate the result of the `lint` command. The `--fail-level` provided for `regal lint` may be
26+
used to change the exit code behavior, and allows a value of either `warning` or `error` (default).
27+
28+
If `--fail-level error` is supplied, exit code will be zero even if warnings are present:
29+
30+
- `0`: no errors were found
31+
- `0`: one or more warnings were found
32+
- `3`: one or more errors were found
33+
34+
This is the default behavior.
35+
36+
If `--fail-level warning` is supplied, warnings will result in a non-zero exit code:
37+
38+
- `0`: no errors or warnings were found
39+
- `2`: one or more warnings were found
40+
- `3`: one or more errors were found
41+
42+
## OPA Check and Strict Mode
43+
44+
OPA itself provides a "linter" of sorts, via the `opa check` command and its `--strict` flag. This checks the provided
45+
Rego files not only for syntax errors, but also for OPA
46+
[strict mode](https://www.openpolicyagent.org/docs/policy-language/#strict-mode) violations. Most of the strict
47+
mode checks from before OPA 1.0 have now been made default checks in OPA, and only two additional checks are currently
48+
provided by the `--strict` flag. Those are both important checks not covered by Regal though, so our recommendation is
49+
to run `opa check --strict` against your policies before linting with Regal.
50+
51+
## Community
52+
53+
For questions, discussions and announcements related to Styra products, services and open source projects, please join
54+
the Styra community on [Slack](https://inviter.co/styra)!

docs/cli.md.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sidebar_position: 4
2+
sidebar_label: CLI

docs/configuration/_category_.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "collapsed": true, "label": "Configuration" }
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<!-- markdownlint-disable MD041 -->
2-
3-
## Capabilities
1+
# Capabilities
42

53
By default, Regal will lint your policies using the
64
[capabilities](https://www.openpolicyagent.org/docs/deployments/#capabilities) of the latest version of OPA
@@ -57,7 +55,7 @@ capabilities:
5755
type: object
5856
```
5957

60-
### Loading Capabilities from URLs
58+
## Loading Capabilities from URLs
6159

6260
Starting with Regal version v0.26.0, Regal can load capabilities from URLs with the `http`, or `https` schemes using
6361
the `capabilities.from.url` config key. For example, to load capabilities from `https://example.org/capabilities.json`,
@@ -69,11 +67,16 @@ capabilities:
6967
url: https://example.org/capabilities.json
7068
```
7169

72-
### Supported Engines
70+
## Supported Engines
7371

7472
Regal includes capabilities files for the following engines:
7573

7674
| Engine | Website | Description |
7775
| ------ | --------------------------------------------------------------- | -------------------- |
7876
| `opa` | [OPA website](https://www.openpolicyagent.org/) | Open Policy Agent |
7977
| `eopa` | [Enterprise OPA website](https://www.styra.com/enterprise-opa/) | Styra Enterprise OPA |
78+
79+
## Community
80+
81+
For questions, discussions and announcements related to Styra products, services and open source projects, please join
82+
the Styra community on [Slack](https://inviter.co/styra)!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sidebar_position: 5
Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<!-- markdownlint-disable MD041 -->
2-
3-
## Ignoring Rules
1+
# Ignoring Rules
42

53
If one of Regal's rules doesn't align with your team's preferences, don't worry! Regal is not meant to be the law,
64
and some rules may not make sense for your project, or parts of it.
@@ -29,7 +27,7 @@ It's also possible to ignore messages on a per-file basis. The available methods
2927
- [Ignoring Files Globally](#ignoring-files-globally) or
3028
[Ignoring a Rule in Some Files](#ignoring-a-rule-in-some-files).
3129

32-
### Ignoring a Rule in Config
30+
## Ignoring a Rule in Config
3331

3432
If you want to ignore a rule, set its level to `ignore` in the configuration file:
3533

@@ -41,7 +39,7 @@ rules:
4139
level: ignore
4240
```
4341
44-
### Ignoring a Category in Config
42+
## Ignoring a Category in Config
4543
4644
If you want to ignore a category of rules, set its default level to `ignore` in the configuration file:
4745

@@ -52,7 +50,7 @@ rules:
5250
level: ignore
5351
```
5452

55-
### Ignoring All Rules in Config
53+
## Ignoring All Rules in Config
5654

5755
If you want to ignore all rules, set the default level to `ignore` in the configuration file:
5856

@@ -71,7 +69,7 @@ rules:
7169

7270
**Tip**: providing a comment on ignored rules is a good way to communicate why the decision was made.
7371

74-
### Ignoring a Rule in Some Files
72+
## Ignoring a Rule in Some Files
7573

7674
You can use the `ignore` attribute inside any rule configuration to provide a list of files, or patterns, that should
7775
be ignored for that rule:
@@ -89,7 +87,7 @@ rules:
8987
- "scratch.rego"
9088
```
9189

92-
### Ignoring Files Globally
90+
## Ignoring Files Globally
9391

9492
**Note**: Ignoring files will disable most language server features
9593
for those files. Only formatting will remain available.
@@ -105,7 +103,7 @@ ignore:
105103
- "*_tmp.rego"
106104
```
107105

108-
### Inline Ignore Directives
106+
## Inline Ignore Directives
109107

110108
If you'd like to ignore a specific violation in a file, you can add an ignore directive above the line in question, or
111109
alternatively on the same line to the right of the expression:
@@ -129,7 +127,7 @@ Note that at this point in time, Regal only considers the same line or the line
129127
does not apply to entire blocks of code (like rules, functions or even packages). See [configuration](#configuration)
130128
if you want to ignore certain rules altogether.
131129

132-
### Ignoring Rules via CLI Flags
130+
## Ignoring Rules via CLI Flags
133131

134132
For development and testing, rules or classes of rules may quickly be enabled or disabled using the relevant CLI flags
135133
for the `regal lint` command:
@@ -143,3 +141,8 @@ for the `regal lint` command:
143141
- `--ignore-files` ignores files using glob patterns, overriding `ignore` in the config file (may be repeated)
144142

145143
**Note:** all CLI flags override configuration provided in file.
144+
145+
## Community
146+
147+
For questions, discussions and announcements related to Styra products, services and open source projects, please join
148+
the Styra community on [Slack](https://inviter.co/styra)!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sidebar_position: 6

0 commit comments

Comments
 (0)