Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add utility function for retrieving the rules in a bundle [CFG-1291] #124

Merged
merged 1 commit into from
Dec 17, 2021

Conversation

teodora-sandu
Copy link
Contributor

What this does

This functionality was first introduced in #121 but that PR is blocked behind a bug in OPA. This PR extracts the utility function from that PR, which just retrieves the publicIds for all rego rules in a bundle - including duplicates.

Notes for the reviewer

  • OPA introduced a new command called inspect which helps us find all the rego rules in a folder: https://github.com/open-policy-agent/opa/blob/main/cmd/inspect.go
  • The majority of the code is not exposed in the Golang module so we are adapting a couple lines to read all the rego rules in a folder.
  • The inspect command only looks at files and not the contents - but we need a way to get the publicId
  • The way we get the publicId is by reading each file and using a regex to extract the publicId which would be configured in a publicId key - the regex allows for any spacing so that no matter what tabbing and newline characters the customer uses, we will retrieve it

More information

@teodora-sandu teodora-sandu marked this pull request as ready for review December 15, 2021 11:32
@teodora-sandu teodora-sandu requested a review from a team as a code owner December 15, 2021 11:32
@teodora-sandu
Copy link
Contributor Author

@aron This just extracts the utility function from #121, which you already reviewed. It makes most sense for you to look at it but let me know if you'd rather I ask someone else

@teodora-sandu teodora-sandu merged commit 13bf028 into develop Dec 17, 2021
@teodora-sandu teodora-sandu deleted the chore/add-inspect-utility branch December 17, 2021 10:48
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