From f6b37330f356f423a0076c0b522fbd15e90f8aab Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 5 Nov 2024 15:18:52 +0100 Subject: [PATCH] Set status to succeeded when the reason is Completed When a task is skipped, the reason becomes Completed, which shows as succeeded (Completed). This can be confusing compared to other tasks that are succeeded but not completed. Users would not be able to tell the difference when they essentially mean the same thing. Therefore, set the status to succeeded when the reason is Completed without displaying the reason. --- pkg/formatted/k8s.go | 4 +++- pkg/formatted/k8s_test.go | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/formatted/k8s.go b/pkg/formatted/k8s.go index 00cfb0d439..50829e8248 100644 --- a/pkg/formatted/k8s.go +++ b/pkg/formatted/k8s.go @@ -67,7 +67,9 @@ func Condition(c v1.Conditions) string { status = "Running" } - if c[0].Reason != "" && c[0].Reason != status { + if c[0].Reason == "Completed" && status == "Succeeded" { + return ColorStatus(status) + } else if c[0].Reason != "" && c[0].Reason != status { switch c[0].Reason { case "PipelineRunCancelled", "TaskRunCancelled", "Cancelled": return ColorStatus("Cancelled") + "(" + c[0].Reason + ")" diff --git a/pkg/formatted/k8s_test.go b/pkg/formatted/k8s_test.go index 623b2db2a1..0ad83a01a5 100644 --- a/pkg/formatted/k8s_test.go +++ b/pkg/formatted/k8s_test.go @@ -73,6 +73,15 @@ func TestCondition(t *testing.T) { }}, want: "Running", }, + { + name: "PipelineRunCompleted status reason", + condition: []apis.Condition{{ + Type: apis.ConditionSucceeded, + Status: corev1.ConditionTrue, + Reason: "Completed", + }}, + want: "Succeeded", + }, { name: "PipelineRunCanceled status reason", condition: []apis.Condition{{