Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions antora/docs/modules/ROOT/pages/release_policy.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1758,10 +1758,8 @@ Ensure that all of the Tasks in the Pipeline completed successfully. Note that s

The Tekton Task used is or will be unsupported. The Task is annotated with `build.appstudio.redhat.com/expires-on` annotation marking it as unsupported after a certain date.

*Solution*: Upgrade to a newer version of the Task.

* Rule type: [rule-type-indicator failure]#FAILURE#
* FAILURE message: `Task %q is used by pipeline task %q is or will be unsupported as of %s.`
* FAILURE message: `Task %q is used by pipeline task %q is or will be unsupported as of %s. %s`
* Code: `tasks.unsupported`
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/tasks.rego#L240[Source, window="_blank"]

Expand Down
4 changes: 4 additions & 0 deletions antora/docs/modules/ROOT/pages/tasks.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ A Task can be set to expire by setting the
annotation means that the task is or will be unsupported by a certain date/time
provided in the value of the annotation in the RFC3339 format.

By default, the rule will prompt the user to `Update to a newer version of the Task.`.
The message can be customized by setting the `build.appstudio.redhat.com/expiry-message`
annotation.

For example, this will set the Task to be unsupported after 2025-01-01 at
midnight UTC; prior to that a warning will be emited by the
xref:release_policy.adoc#tasks__unsupported[Task version unsupported] rule and
Expand Down
13 changes: 9 additions & 4 deletions policy/release/tasks.rego
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,7 @@ deny contains result if {
# custom:
# short_name: unsupported
# 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.

# Task %q is used by pipeline task %q is or will be unsupported as of %s. %s
# collections:
# - redhat
# depends_on:
Expand All @@ -261,11 +259,16 @@ deny contains result if {
annotations := tkn.task_annotations(task)

expires_on := annotations[_expires_on_annotation]
expiry_message := object.get(
annotations,
_expiry_msg_annotation,
"Upgrade to a newer version of the Task.",
)

result := object.union(
lib.result_helper_with_term(
rego.metadata.chain(),
[tkn.task_name(task), tkn.pipeline_task_name(task), expires_on],
[tkn.task_name(task), tkn.pipeline_task_name(task), expires_on, expiry_message],
tkn.task_name(task),
),
{"effective_on": expires_on},
Expand Down Expand Up @@ -385,3 +388,5 @@ _format_missing(o, opt) := desc if {
} else := sprintf("Required task %q", [o])

_expires_on_annotation := "build.appstudio.redhat.com/expires-on"

_expiry_msg_annotation := "build.appstudio.redhat.com/expiry-message"
Comment thread
lcarva marked this conversation as resolved.
33 changes: 29 additions & 4 deletions policy/release/tasks_test.rego
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,8 @@ test_deprecated_slsa_v0_2 if {

expected := {{
"code": "tasks.unsupported",
"msg": `Task "task" is used by pipeline task "task" is or will be unsupported as of 2200-01-01T00:00:00Z.`,
# regal ignore:line-length
"msg": `Task "task" is used by pipeline task "task" is or will be unsupported as of 2200-01-01T00:00:00Z. Upgrade to a newer version of the Task.`,
"term": "task",
}}

Expand All @@ -605,7 +606,8 @@ test_expired_slsa_v0_2 if {

expected := {{
"code": "tasks.unsupported",
"msg": `Task "task" is used by pipeline task "task" is or will be unsupported as of 2000-01-01T00:00:00Z.`,
# regal ignore:line-length
"msg": `Task "task" is used by pipeline task "task" is or will be unsupported as of 2000-01-01T00:00:00Z. Upgrade to a newer version of the Task.`,
"term": "task",
}}

Expand All @@ -622,7 +624,8 @@ test_deprecated_slsa_v1 if {

expected := {{
"code": "tasks.unsupported",
"msg": `Task "task" is used by pipeline task "task" is or will be unsupported as of 2200-01-01T00:00:00Z.`,
# regal ignore:line-length
"msg": `Task "task" is used by pipeline task "task" is or will be unsupported as of 2200-01-01T00:00:00Z. Upgrade to a newer version of the Task.`,
"term": "task",
}}

Expand All @@ -639,7 +642,29 @@ test_expired_slsa_v1 if {

expected := {{
"code": "tasks.unsupported",
"msg": `Task "task" is used by pipeline task "task" is or will be unsupported as of 2000-01-01T00:00:00Z.`,
# regal ignore:line-length
"msg": `Task "task" is used by pipeline task "task" is or will be unsupported as of 2000-01-01T00:00:00Z. Upgrade to a newer version of the Task.`,
"term": "task",
}}

lib.assert_equal_results(tasks.deny, expected) with input.attestations as attestation
with data["pipeline-required-tasks"] as {"generic": []}
with data["task-bundles"] as _trusted_tasks
}

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.",
Comment on lines +655 to +660

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

}}}},
)])

expected := {{
"code": "tasks.unsupported",
# regal ignore:line-length
"msg": `Task "task" is used by pipeline task "task" is or will be unsupported as of 2000-01-01T00:00:00Z. The Task has been discontinued.`,
"term": "task",
}}

Expand Down