Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion util/conditions/setter.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ func Delete(to Setter, conditionType string) {
}

conditions := to.GetConditions()
newConditions := make([]metav1.Condition, 0, len(conditions)-1)
// allocate same length array because the conditions length might be 0
// or the condition to be deleted might not be part of the list.
newConditions := make([]metav1.Condition, 0, len(conditions))
for _, condition := range conditions {
if condition.Type != conditionType {
newConditions = append(newConditions, condition)
Expand Down
4 changes: 3 additions & 1 deletion util/deprecated/v1beta1/conditions/v1beta2/setter.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ func Delete(to Setter, conditionType string) {
}

conditions := to.GetV1Beta2Conditions()
newConditions := make([]metav1.Condition, 0, len(conditions)-1)
// allocate same length array because the conditions length might be 0
// or the condition to be deleted might not be part of the list.
newConditions := make([]metav1.Condition, 0, len(conditions))
for _, condition := range conditions {
if condition.Type != conditionType {
newConditions = append(newConditions, condition)
Expand Down