Skip to content

Make the task expiry message customizable#1156

Merged
lcarva merged 1 commit into
conforma:mainfrom
chmeliik:customize-task-expiry-message
Sep 26, 2024
Merged

Make the task expiry message customizable#1156
lcarva merged 1 commit into
conforma:mainfrom
chmeliik:customize-task-expiry-message

Conversation

@chmeliik

@chmeliik chmeliik commented Sep 26, 2024

Copy link
Copy Markdown
Contributor

Note: this came from an internal Slack conversation about how to distinguish between "task is deprecated because we only maintain the newer version" and "task is discontinued". Somewhat related to konflux-ci/build-definitions#1471 (comment)

Along with the expires-on annotation, Task authors can optionally define the expiry-message annotation to override the default expiry message. The default is still "Upgrade to a newer version of the Task."

This required moving the 'solution' part of the rule into the 'failure_msg' instead, because 'solution' does not support templating.

Comment thread policy/release/tasks.rego
# failure_msg: >-
# Task %q is used by pipeline task %q is or will be unsupported as of %s.
# solution: >-
# Upgrade to a newer version of the Task.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure how important it is for the solution to be in solution rather than in failure_msg. I can look into making the solution template-able, but I would need some help with that

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.

I think this is fine.

Comment on lines +651 to +660
test_expired_with_custom_message if {
attestation := _slsav1_attestations_with_tasks({}, [object.union(
_task("task"),
{"invocation": {"environment": {"annotations": {
tasks._expires_on_annotation: "2000-01-01T00:00:00Z",
tasks._expiry_msg_annotation: "The Task has been discontinued.",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I noticed the other test case is kinda quadrupled - [slsav0_2, slsav1] X [already expired, expires in the future]

It didn't seem necessary to cover the expiry message for all 4 cases, but LMK if that's incorrect

Comment thread policy/release/tasks.rego
@codecov-commenter

codecov-commenter commented Sep 26, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (66c1925) to head (d341d72).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main     #1156   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          117       117           
  Lines         6042      6053   +11     
=========================================
+ Hits          6042      6053   +11     
Files with missing lines Coverage Δ
policy/release/tasks.rego 100.00% <100.00%> (ø)
policy/release/tasks_test.rego 100.00% <100.00%> (ø)

@lcarva

lcarva commented Sep 26, 2024

Copy link
Copy Markdown
Contributor

Some linting failures. Add the comment # regal ignore:line-length above the lines flagged as too long.

@chmeliik

Copy link
Copy Markdown
Contributor Author

Now it's saying there are uncommitted changes, but I'm not sure what they are

@lcarva

lcarva commented Sep 26, 2024

Copy link
Copy Markdown
Contributor

Now it's saying there are uncommitted changes, but I'm not sure what they are

make generate-docs

Along with the expires-on annotation, Task authors can optionally define
the expiry-message annotation to override the default expiry message.
The default is still "Upgrade to a newer version of the Task."

This required moving the 'solution' part of the rule into the
'failure_msg' instead, because 'solution' does not support templating.

Signed-off-by: Adam Cmiel <acmiel@redhat.com>
@chmeliik chmeliik force-pushed the customize-task-expiry-message branch from 5b4cc49 to d341d72 Compare September 26, 2024 14:51
@lcarva lcarva merged commit 1c21485 into conforma:main Sep 26, 2024
@chmeliik chmeliik deleted the customize-task-expiry-message branch September 26, 2024 15:04
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.

3 participants