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

Support _one of_ for required tasks #789

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

zregvart
Copy link
Member

This adds support for the notion of one of required tasks from the required tasks list.

For example, given required tasks data as:

 - A
 - [B, C, D]
 - E

Tasks "A", at least one of "B", "C" or "D", and "E" are required.

@zregvart
Copy link
Member Author

Created as draft, support for the pipeline rules needs to be added.

}

_any_missing(required, tasks) := missing if {
# one of required tasks is required
is_array(required)
Copy link
Member

Choose a reason for hiding this comment

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

Could use a helper method to avoid having to implement the logic for both cases, e.g.

_any_missing(required, tasks) := missing if {
  req := setfy(required)
  tsk := setfy(tasks)
  ...
}

setfy(o) := s if {
  s := {v | some v in o}
} else := {o}

This could maybe reside in policy/lib/set_helpers.rego.

Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out we already have that helper there :)

Copy link
Member

Choose a reason for hiding this comment

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

I think it would've been nice to unify the two use cases (array vs non-array) which is what I was trying to drive at with this comment. But anyways, the current approach works just as well 😉

@zregvart zregvart force-pushed the issue/RHTAPBUGS-914 branch from 0f030b0 to b3ae211 Compare November 2, 2023 14:57
@zregvart zregvart marked this pull request as ready for review November 2, 2023 14:58
@codecov-commenter
Copy link

Codecov Report

Merging #789 (b3ae211) into main (0ed9fe3) will not change coverage.
Report is 4 commits behind head on main.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #789   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           86        86           
  Lines         3342      3425   +83     
=========================================
+ Hits          3342      3425   +83     
Files Coverage Δ
policy/pipeline/required_tasks.rego 100.00% <100.00%> (ø)
policy/pipeline/required_tasks_test.rego 100.00% <100.00%> (ø)
policy/release/tasks.rego 100.00% <100.00%> (ø)
policy/release/tasks_test.rego 100.00% <100.00%> (ø)

This adds support for the notion of _one of_ required tasks from the
required tasks list.

For example, given required tasks data as:

```yaml
 - A
 - [B, C, D]
 - E
```

Tasks "A", at least one of "B", "C" or "D", and "E" are required.
@zregvart zregvart force-pushed the issue/RHTAPBUGS-914 branch from b3ae211 to d4e9abf Compare November 2, 2023 15:36
@zregvart zregvart merged commit d56f09d into enterprise-contract:main Nov 2, 2023
3 checks passed
@zregvart zregvart deleted the issue/RHTAPBUGS-914 branch November 2, 2023 15:38
zregvart added a commit to zregvart/rhtap-ec-policy that referenced this pull request Nov 2, 2023
With the enterprise-contract/ec-policies#789
merged we can support 'one of' semantic in required task. This changes
the definition of required tasks so one of buildah task variants is
required.

reference: https://issues.redhat.com/browse/RHTAPBUGS-914
@simonbaird
Copy link
Member

Nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants