Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛fix: removes use of slices.DeleteFunc because it zeros the elements a… #29

Merged
merged 1 commit into from
Nov 4, 2024
Merged
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
11 changes: 7 additions & 4 deletions cmd/clusterctl/client/cluster/cert_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package cluster
import (
"context"
_ "embed"
"slices"
"time"

"github.com/blang/semver/v4"
Expand Down Expand Up @@ -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
Comment on lines +348 to +354
Copy link
Collaborator

@dkoshkin dkoshkin Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is this easier to read?

Suggested change
newObjs := []unstructured.Unstructured{}
for _, o := range objs {
if !(o.GetKind() == "Endpoints" || o.GetKind() == "EndpointSlice") {
newObjs = append(newObjs, o)
}
}
objs = newObjs
// skip resources 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
newObjs := []unstructured.Unstructured{}
for _, o := range objs {
if o.GetKind() == "Endpoints" || o.GetKind() == "EndpointSlice" {
contiune
}
newObjs = append(newObjs, o)
}
objs = newObjs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i guess the boolean logic there is a little confusing but it reads in less lines?

for i := range objs {
obj := objs[i]

Expand Down
Loading