Skip to content

Allow to pass multiple policies in the cli#4948

Open
LecrisUT wants to merge 1 commit into
teemtee:mainfrom
LecrisUT:feat/multi-policy
Open

Allow to pass multiple policies in the cli#4948
LecrisUT wants to merge 1 commit into
teemtee:mainfrom
LecrisUT:feat/multi-policy

Conversation

@LecrisUT
Copy link
Copy Markdown
Member

@LecrisUT LecrisUT commented Jun 1, 2026

No description provided.

Signed-off-by: Cristian Le <git@lecris.dev>
@LecrisUT LecrisUT added code | cli Changes related to the command line interface ci | full test Pull request is ready for the full test execution labels Jun 1, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread tests/policy/test-test.sh
}
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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

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.

Suggested change
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"

Comment thread tmt/cli/_root.py
Comment on lines +73 to +74
policy_name: list[str],
policy_path: list[Path],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
policy_name: list[str],
policy_path: list[Path],
policy_name: tuple[str, ...],
policy_path: tuple[Path, ...],

@github-project-automation github-project-automation Bot moved this to backlog in planning Jun 3, 2026
@AthreyVinay AthreyVinay moved this from backlog to review in planning Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci | full test Pull request is ready for the full test execution code | cli Changes related to the command line interface

Projects

Status: review

Development

Successfully merging this pull request may close these issues.

2 participants