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

rego-v1: Future-proofing format pkg tests to be 1.0 compatible #7010

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

johanfylling
Copy link
Contributor

No description provided.

@@ -0,0 +1,11 @@
package test.contains2 # FIXME: refs aren't allowed to contains keywords
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out, not allowing keywords in refs is an actual issue in v1, and not just a nuisance.

We can make the test.contains package parse by bracketing it: test["contains"].
This is however not only ugly for no actual benefit, but the formatter will actually output it as package test.contains, which won't parse 😞.

We could fix the formatter to output package test["contains"] instead. But I think we should instead allow refs to contain keywords.

Copy link
Member

Choose a reason for hiding this comment

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

But I think we should instead allow refs to contain keywords.

Was there a reason to not allow refs to contain keywords?

We could fix the formatter to output package test["contains"]

We could update the --rego-v1 flag to do that. But as you said we should allow refs unless there is a good reason not to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the argument against allowing keywords in refs is that we don't allow such rule names, e.g.

package foo

if if { true } # error: 'if' is not a valid rule name

but we allow you to create an empty module:

package foo.if

which would generate an empty virtual document at data.foo.if. This creates a sort of parity mismatch, where we allow you to create data.foo.if one way, but not the other.

Copy link
Member

Choose a reason for hiding this comment

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

That can still be created via JSON data, so won't that mismatch always exist? The question is why you wouldn't be allowed to reference such data (without special handling / quoting) where it's impossible for it to clash with a keyword... i.e. input.package is obviously distinctly different from package alone.

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.

3 participants