Allow to pass multiple policies in the cli#4948
Conversation
Signed-off-by: Cristian Le <git@lecris.dev>
There was a problem hiding this comment.
Code Review
This pull request enables loading multiple policies by updating --policy-name and --policy-file to accept multiple values, modifying _load_policies and related CLI commands to handle lists of policies, and adding a test case. Feedback highlights that the test assertion using yq always passes and should use grep instead, and that type annotations for the multiple-value options should be tuple instead of list since Click passes tuples.
| } | ||
| run_test | ||
| rlRun "yq '.[0] | .test' $rlRun_LOG | grep -- 'bash -c'" 0 "Test policy was applied" | ||
| rlRun "yq '.[0] | .contact == \"xyzzy\"' $rlRun_LOG" 0 "Test policy was applied" |
There was a problem hiding this comment.
The assertion always passes because yq exits with 0 even if the expression evaluates to false. Use grep to verify the output value, similar to line 77.
| rlRun "yq '.[0] | .contact == \"xyzzy\"' $rlRun_LOG" 0 "Test policy was applied" | |
| rlRun "yq '.[0] | .contact[0]' $rlRun_LOG | grep -q 'xyzzy'" 0 "Contact policy was applied" |
| policy_name: list[str], | ||
| policy_path: list[Path], |
There was a problem hiding this comment.
Use tuple[str, ...] and tuple[Path, ...] instead of list because Click passes tuples for options with multiple=True. Apply this to _load_policies, run, tests_export, and plans_export.
| policy_name: list[str], | |
| policy_path: list[Path], | |
| policy_name: tuple[str, ...], | |
| policy_path: tuple[Path, ...], |
No description provided.