+
Skip to content

Conversation

anderseknert
Copy link
Contributor

Hi there, GKE friends 👋😃

This PR introduces Regal for linting Rego policy for the project. I've limited linting (and fixes) to the gke-policies-v2 directory here, but I'd be happy to expand this to the v1 directory as well if you think that'd be valuable.

Along with a configuration file to disable some of the linters that'd require a more concentrated effort to adhere to, I've fixed the following reported violations, which while mostly style-related, seems like they'd be good to enforce for modern Rego:

I've also included linting as a step for the GitHub Action that runs tests of all the policies.

Let me know what you think!

@google-cla
Copy link

google-cla bot commented Oct 15, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@mikouaj mikouaj self-assigned this Oct 18, 2023
Hi there, GKE friends 👋😃

This PR introduces [Regal](https://github.com/StyraInc/regal) for linting Rego policy
for the project. I've limited linting (and fixes) to the `gke-policies-v2` directory
here, but I'd be happy to expand this to the v1 directory as well if you think that'd
be valuable.

Along with a configuration file to disable some of the linters that'd require a more
concentrated effort to adhere to, I've fixed the following reported violations, which
while mostly style-related, seems like they'd be good to enforce for modern Rego:

* [use-some-for-output-vars](https://docs.styra.com/regal/rules/use-some-for-output-vars)
* [non-raw-regex-pattern](https://docs.styra.com/regal/rules/idiomatic/non-raw-regex-pattern)
* [prefer-package-imports](https://docs.styra.com/regal/rules/imports/prefer-package-imports)
* [chained-rule-body](https://docs.styra.com/regal/rules/style/chained-rule-body)
* [identically-named-tests](https://docs.styra.com/regal/rules/testing/identically-named-tests)
* [use-assignment-operator](https://docs.styra.com/regal/rules/style/use-assignment-operator)

I've also included linting as a step for the GitHub Action that runs tests of all the
policies.

Let me know what you think!

Signed-off-by: Anders Eknert <anders@styra.com>
@anderseknert
Copy link
Contributor Author

Pushed update to include copyright header in .regal/config.yaml.

Copy link
Member

@mikouaj mikouaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @anderseknert for introducing Regal to our project!
Its a really useful tool and I will definitely consider it in the other projects as well. Also I will scan ignored rules and see what else can we adapt.

@anderseknert
Copy link
Contributor Author

I'm very happy to hear that @mikouaj! 😃 Let me know if there's anything I can do to help with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载