Skip to content

Commit d7234fb

Browse files
Refine order for v1beta2 summary util
1 parent 029b8c9 commit d7234fb

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

util/conditions/v1beta2/merge_strategies.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ func (d *defaultMergeStrategy) Merge(conditions []ConditionWithOwnerInfo, condit
259259
// provided by the user (it is considered as order of relevance).
260260
if isSummaryOperation {
261261
messages := []string{}
262-
for _, condition := range append(issueConditions, append(unknownConditions, infoConditions...)...) {
262+
263+
// Note: use conditions because we want to preserve the order of relevance defined by the users (the order of condition types).
264+
for _, condition := range conditions {
263265
priority := d.getPriorityFunc(condition.Condition)
264266
if priority == InfoMergePriority {
265267
// Drop info messages when we are surfacing issues or unknown.

util/conditions/v1beta2/summary_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ func TestSummary(t *testing.T) {
116116
Type: clusterv1.AvailableV1Beta2Condition,
117117
Status: metav1.ConditionFalse, // False because there are many issues
118118
Reason: issuesReportedReason, // Using a generic reason
119-
Message: "* B: Message-B\n" +
120-
"* !C: Message-!C\n" +
121-
"* A: Message-A", // messages from all the issues & unknown conditions (info dropped)
119+
Message: "* A: Message-A\n" +
120+
"* B: Message-B\n" +
121+
"* !C: Message-!C", // messages from all the issues & unknown conditions (info dropped); also, the order defined in ForConditionTypes must be preserved.
122122
},
123123
},
124124
{

0 commit comments

Comments
 (0)