From dfc63827e3aeda5433d87a404e59970da266bc22 Mon Sep 17 00:00:00 2001 From: faiq Date: Mon, 4 Nov 2024 10:33:14 -0800 Subject: [PATCH] fix: removes use of slices.DeleteFunc because it zeros the elements and doesn't remove those from obj list --- cmd/clusterctl/client/cluster/cert_manager.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/clusterctl/client/cluster/cert_manager.go b/cmd/clusterctl/client/cluster/cert_manager.go index 88426eab8ea2..b40c2b7479d8 100644 --- a/cmd/clusterctl/client/cluster/cert_manager.go +++ b/cmd/clusterctl/client/cluster/cert_manager.go @@ -19,7 +19,6 @@ package cluster import ( "context" _ "embed" - "slices" "time" "github.com/blang/semver/v4" @@ -346,9 +345,13 @@ func (cm *certManagerClient) shouldUpgrade(desiredVersion string, objs, installO // removes resources that are generated by the kubernetes API // this is relevant if the versions are the same, because we compare // the number of objects when version of objects are equal - objs = slices.DeleteFunc(objs, func(obj unstructured.Unstructured) bool { - return obj.GetKind() == "Endpoints" || obj.GetKind() == "EndpointSlice" - }) + newObjs := []unstructured.Unstructured{} + for _, o := range objs { + if !(o.GetKind() == "Endpoints" || o.GetKind() == "EndpointSlice") { + newObjs = append(newObjs, o) + } + } + objs = newObjs for i := range objs { obj := objs[i]