-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds [Regal](https://github.com/styraInc/regal) for linting the Rego contained in this repo. Practically, this PR adds a Regal configuration file adapted to the project, where some of the most reported style issues are ignoed for the time being. Additionally, we're adding a linter job to the CI pipeline to ensure future updates to policy if compliant as well. A few (hopefully) uncontroversial issues reported have also been fixed: * [constant-condition](https://docs.styra.com/regal/rules/bugs/constant-condition) * [use-assignment-operator](https://docs.styra.com/regal/rules/style/use-assignment-operator) * [use-in-operator](https://docs.styra.com/regal/rules/idiomatic/use-in-operator) * [use-some-for-output-vars](https://docs.styra.com/regal/rules/idiomatic/use-some-for-output-vars) * [non-raw-regex-pattern](https://docs.styra.com/regal/rules/idiomatic/non-raw-regex-pattern) While the changes are non-intrusive, and should have no impact on evaluation, I naturally wanted to run the tests included in this repo and followed the instructions in TESTING.md. However, even after having installed all of the dependencies listed as required, the test command fails due to a missing `oc` command. I tried to find that and possibly update the TESTING.md file to include it, but the instructions I followed suggested logging in to a "RedHat Customer Portal" to get it. If being a customer is required to run the tests, that requirement would be good to add to the docs as well. Signed-off-by: Anders Eknert <[email protected]>
- Loading branch information
1 parent
090de51
commit ddc427e
Showing
11 changed files
with
129 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Lint policies with Regal | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint-policy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Regal | ||
uses: StyraInc/[email protected] | ||
with: | ||
version: v0.10.1 | ||
|
||
- name: Run Regal lint | ||
run: regal lint --format github policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
rules: | ||
idiomatic: | ||
no-defined-entrypoint: | ||
level: ignore | ||
style: | ||
avoid-get-and-list-prefix: | ||
level: ignore | ||
external-reference: | ||
level: ignore | ||
line-length: | ||
level: ignore | ||
no-whitespace-comment: | ||
level: ignore | ||
opa-fmt: | ||
level: ignore | ||
prefer-some-in-iteration: | ||
level: ignore | ||
prefer-snake-case: | ||
# 13 violations in the repo seems easy to fix | ||
level: ignore | ||
todo-comment: | ||
level: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.