Migrate test policies to Rego v1#6462
Conversation
6a2f24a to
19d8a53
Compare
19d8a53 to
88c74c3
Compare
|
@JAORMX , @evankanderson |
evankanderson
left a comment
There was a problem hiding this comment.
Sorry for the delayed review, and thanks for cleaning these up! A couple questions before I merge.
| package minder | ||
|
|
||
| import future.keywords.if | ||
| import rego.v1 |
There was a problem hiding this comment.
Do we need import rego.v1 with the detection we've implemented? (I think it's fine to leave it in, just curious.)
| name: "v1 policy with keyword syntax", | ||
| def: ` | ||
| package minder | ||
|
|
||
| import future.keywords.if | ||
| import future.keywords.in | ||
| import rego.v1 | ||
|
|
||
| default allow = false | ||
| default allow := false | ||
|
|
||
| allow if { | ||
| "admin" in input.profile.roles | ||
| }`, |
There was a problem hiding this comment.
Doesn't this change this test into the next case?
(I think you want to revert this specific test change)
It would also be good to have a test which uses the v1 syntax but does not import rego.v1 explicitly, to show whether that is accepted or an error.
Signed-off-by: dakshhhhh16 <daksh.pathak.ug24@nsut.ac.in>
|
@evankanderson |
evankanderson
left a comment
There was a problem hiding this comment.
Thanks for adding the test that confirmed my behavior expectation. It's possible in the future I'll come in and remove some of these import rego.v1 lines since they aren't necessary (and may distract from the test), but this change seems fine for now.
Same here! I'll myself make these changes after all phases are complete. Will soon come up with the third phase pr. |
Summary
This PR migrates Minder's embedded Rego test fixtures, sample rule YAML, and Rego docs examples to Rego v1 syntax as part of Phase 2 of #5262. (Parent issue)
Child issue #6463
The production evaluator already supports Rego version detection. This change moves the policy corpus we own toward the Rego v1 baseline by replacing v0 syntax and
future.keywordsexamples withimport rego.v1.What changed
import rego.v1.future.keywordsimports.Validation
git diff --checkgo test ./pkg/mindpak ./internal/engine/eval/... ./pkg/engine/v1/rtengine ./pkg/api/protobuf/go/minder/v1 ./cmd/cli/app/ruletype ./cmd/cli/app/quickstartgo test ./...was also attempted. It reaches unrelated failures ininternal/engine/actions/remediate/pull_requestwhere tests cannot create a temporary git repository in this local environment.Notes for reviewers
This is intended to be a syntax-only migration. The remaining v0 snippets in
internal/engine/eval/rego/version_test.goare deliberate detector coverage and do not usefuture.keywords.