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

Add configurable exception case to prefer-some-in-iteration #425

Closed
anderseknert opened this issue Oct 26, 2023 · 0 comments · Fixed by #565
Closed

Add configurable exception case to prefer-some-in-iteration #425

anderseknert opened this issue Oct 26, 2023 · 0 comments · Fixed by #565

Comments

@anderseknert
Copy link
Member

There are a few cases where some .. in can't directly replace [_] iteration. In the gatekeeper-library repo, they do a whole lot of:

input_containers[c] {
    c := input.review.object.spec.containers[_]
}
input_containers[c] {
    c := input.review.object.spec.initContainers[_]
}
input_containers[c] {
    c := input.review.object.spec.ephemeralContainers[_]
}

Which without unconditional-assignment becomes:

input_containers[input.review.object.spec.containers[_]]

input_containers[input.review.object.spec.initContainers[_]]

input_containers[input.review.object.spec.ephemeralContainers[_]]

Using some ... in doesn't work in that location, so the alternative would be:

input_containers[c] {
    some c in input.review.object.spec.ephemeralContainers
}

# or

input_containers contains c if some c in input.review.object.spec.ephemeralContainers

But that's arguably an "unconditional assignment" — or at least an unconditional if — too. If one prefers the shorter [_] syntax in this case I think that should be allowed as an option.

anderseknert added a commit that referenced this issue Feb 20, 2024
Fixes #425

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this issue Feb 20, 2024
Fixes #425

Signed-off-by: Anders Eknert <anders@styra.com>
srenatus pushed a commit to srenatus/regal that referenced this issue Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant