Project condition to filter the scope for a group policy
Sometimes we want to target a group as the source, however in a specific summary we might want to scope it to a specific project. For now, this can be done with an addition Ruby condition like this:
resource_rules:
issues:
rules:
- name: My issue policy
conditions:
ruby: |
resource[:project_id] == 278964
state: opened
labels:
- None
However, this is a bit opaque to the rule because it's difficult to reflect the conditions under an arbitrary Ruby expression. We hit into this issue in gitlab-org/quality/triage-ops#711 (closed)
In short, the resources are properly filtered with the Ruby condition, but the generated heatmap does not have this knowledge to properly generate the link within the scope to this Ruby condition.
We can provide a new option to help this case and it can reflect from the rule easier:
resource_rules:
issues:
rules:
- name: My issue policy
conditions:
project: 278964
state: opened
labels:
- None
If we do so, the heatmap generator can simply look at this conditions.project
and understand that there's an additional filter should be applied to the resources, just like the other conditions.
As a side note, I pick this under limits
rather than conditions
, because generally conditions
are filtered at the API level, and limits
are filtered under Ruby level after taking the responses from the API.
In this sense, Ruby "conditions" should actually be moved under limits
rather than conditions
, but that's already done. We can consider keep that as a legacy option but also support limits.ruby
to be consistent with this concept.