File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -186,11 +186,17 @@ func Delete(to Setter, t clusterv1.ConditionType) {
186
186
to .SetConditions (newConditions )
187
187
}
188
188
189
- // lexicographicLess returns true if a condition is less than another with regards to the
190
- // to order of conditions designed for convenience of the consumer, i.e. kubectl.
189
+ // lexicographicLess returns true if a condition is less than another in regard to
190
+ // the order of conditions designed for convenience of the consumer, i.e. kubectl.
191
191
// According to this order the Ready condition always goes first, followed by all the other
192
192
// conditions sorted by Type.
193
193
func lexicographicLess (i , j * clusterv1.Condition ) bool {
194
+ if i == nil {
195
+ return true
196
+ }
197
+ if j == nil {
198
+ return false
199
+ }
194
200
return (i .Type == clusterv1 .ReadyCondition || i .Type < j .Type ) && j .Type != clusterv1 .ReadyCondition
195
201
}
196
202
Original file line number Diff line number Diff line change @@ -84,6 +84,12 @@ func TestLexicographicLess(t *testing.T) {
84
84
a = TrueCondition ("A" )
85
85
b = TrueCondition (clusterv1 .ReadyCondition )
86
86
g .Expect (lexicographicLess (a , b )).To (BeFalse ())
87
+
88
+ a = TrueCondition ("A" )
89
+ g .Expect (lexicographicLess (a , nil1 )).To (BeFalse ())
90
+
91
+ b = TrueCondition ("A" )
92
+ g .Expect (lexicographicLess (nil1 , b )).To (BeTrue ())
87
93
}
88
94
89
95
func TestSet (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments