mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #99755 from lala123912/out_of_range
fix RemoveStatusCondition() cap out of range
This commit is contained in:
commit
e22e9b4f83
@ -57,7 +57,7 @@ func SetStatusCondition(conditions *[]metav1.Condition, newCondition metav1.Cond
|
|||||||
// RemoveStatusCondition removes the corresponding conditionType from conditions.
|
// RemoveStatusCondition removes the corresponding conditionType from conditions.
|
||||||
// conditions must be non-nil.
|
// conditions must be non-nil.
|
||||||
func RemoveStatusCondition(conditions *[]metav1.Condition, conditionType string) {
|
func RemoveStatusCondition(conditions *[]metav1.Condition, conditionType string) {
|
||||||
if conditions == nil {
|
if conditions == nil || len(*conditions) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
newConditions := make([]metav1.Condition, 0, len(*conditions)-1)
|
newConditions := make([]metav1.Condition, 0, len(*conditions)-1)
|
||||||
|
@ -121,6 +121,12 @@ func TestRemoveStatusCondition(t *testing.T) {
|
|||||||
{Type: "third"},
|
{Type: "third"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "empty_conditions",
|
||||||
|
conditions: []metav1.Condition{},
|
||||||
|
conditionType: "Foo",
|
||||||
|
expected: []metav1.Condition{},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user