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

Ensure rule "name" logic works without rule.head.name #278

Merged
merged 1 commit into from
Aug 30, 2023

Conversation

anderseknert
Copy link
Member

The name attribute is not present in ref-head rules, so make sure things keep working when those are around.

Fixes #276

Note though that the rules don't yet necessarily take all ref names into account. Will look at that separately. Just fix the bug for now.

The name attribute is not present in ref-head rules, so
make sure things keep working when those are around.

Fixes #276

Note though that the rules don't yet necessarily take
all ref names into account. Will look at that separately.
Just fix the bug for now.

Signed-off-by: Anders Eknert <anders@styra.com>
# true
# if true
#
# If you write Rego like that — you're not going to use Regal anyway, are you? ¯\_(ツ)_/¯
Copy link
Member

Choose a reason for hiding this comment

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

😄

Comment on lines +31 to +34
_is_name(ref, pos) if {
pos == 0
ref.type == "var"
}
Copy link
Member

Choose a reason for hiding this comment

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

[golf]

Suggested change
_is_name(ref, pos) if {
pos == 0
ref.type == "var"
}
_is_name(ref, 0) if ref.type == "var"

Copy link
Member Author

Choose a reason for hiding this comment

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

I like it :) And in this case it won't matter, but I remember how "pattern matching" on function args was noticeably slower when done in the hot path of walk traversals.

@anderseknert anderseknert merged commit de1fc97 into main Aug 30, 2023
1 check passed
@anderseknert anderseknert deleted the ref-head-rules branch August 30, 2023 07:25
srenatus pushed a commit to srenatus/regal that referenced this pull request Oct 1, 2024
The name attribute is not present in ref-head rules, so
make sure things keep working when those are around.

Fixes StyraInc#276

Note though that the rules don't yet necessarily take
all ref names into account. Will look at that separately.
Just fix the bug for now.

Signed-off-by: Anders Eknert <anders@styra.com>
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.

Ref-head rules aren't currently handled by Regal
2 participants