Skip to content

Commit dc3ca8e

Browse files
committed
[modernize] run modernize
1 parent 105ae1f commit dc3ca8e

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

internal/controller/aggregates_controller.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,9 @@ func addToAggregate(ctx context.Context, serviceClient *gophercloud.ServiceClien
177177
aggs[name] = aggregate
178178
}
179179

180-
for _, aggHost := range aggregate.Hosts {
181-
if aggHost == host {
182-
log.Info("Found host in aggregate", "host", host, "name", name)
183-
return nil
184-
}
180+
if slices.Contains(aggregate.Hosts, host) {
181+
log.Info("Found host in aggregate", "host", host, "name", name)
182+
return nil
185183
}
186184

187185
result, err := aggregates.AddHost(ctx, serviceClient, aggregate.ID, aggregates.AddHostOpts{Host: host}).Extract()

internal/controller/hypervisor_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func updateLabelsAndAnnotations(node *metav1.ObjectMeta, hypervisor *kvmv1.Hyper
187187
if aggregates, found := node.Annotations[annotationAggregates]; found {
188188
// split aggregates string
189189
hypervisor.Spec.Aggregates = slices.Collect(func(yield func(string) bool) {
190-
for _, agg := range strings.Split(aggregates, ",") {
190+
for agg := range strings.SplitSeq(aggregates, ",") {
191191
trimmed := strings.TrimSpace(agg)
192192
if trimmed != "" && !yield(trimmed) {
193193
return
@@ -200,7 +200,7 @@ func updateLabelsAndAnnotations(node *metav1.ObjectMeta, hypervisor *kvmv1.Hyper
200200
if customTraits, found := node.Annotations[annotationCustomTraits]; found {
201201
// split custom traits string
202202
hypervisor.Spec.CustomTraits = slices.Collect(func(yield func(string) bool) {
203-
for _, trait := range strings.Split(customTraits, ",") {
203+
for trait := range strings.SplitSeq(customTraits, ",") {
204204
trimmed := strings.TrimSpace(trait)
205205
if trimmed != "" && !yield(trimmed) {
206206
return

0 commit comments

Comments
 (0)