mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +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.
|
||||
// conditions must be non-nil.
|
||||
func RemoveStatusCondition(conditions *[]metav1.Condition, conditionType string) {
|
||||
if conditions == nil {
|
||||
if conditions == nil || len(*conditions) == 0 {
|
||||
return
|
||||
}
|
||||
newConditions := make([]metav1.Condition, 0, len(*conditions)-1)
|
||||
|
@ -121,6 +121,12 @@ func TestRemoveStatusCondition(t *testing.T) {
|
||||
{Type: "third"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty_conditions",
|
||||
conditions: []metav1.Condition{},
|
||||
conditionType: "Foo",
|
||||
expected: []metav1.Condition{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Loading…
Reference in New Issue
Block a user