Skip to content

Commit 00dbcd3

Browse files
[release-v1.35] update go to 1.26.1 (#913)
* update go to 1.26.1 Signed-off-by: Felix Breuer <f.breuer94@gmail.com> * fix atomic uint64 Signed-off-by: Felix Breuer <f.breuer94@gmail.com> --------- Signed-off-by: Felix Breuer <f.breuer94@gmail.com> Co-authored-by: Felix Breuer <f.breuer94@gmail.com>
1 parent 41a3f60 commit 00dbcd3

22 files changed

+504
-527
lines changed

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ linters:
2020
- importas
2121
- ineffassign
2222
- misspell
23+
- modernize
2324
- nakedret
2425
- noctx
2526
- nolintlint

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/stackitcloud/cloud-provider-stackit
22

3-
go 1.25.0
4-
5-
toolchain go1.26.1
3+
go 1.26.1
64

75
require (
86
github.com/container-storage-interface/spec v1.12.0

pkg/ccm/instances_test.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"go.uber.org/mock/gomock"
3030
corev1 "k8s.io/api/core/v1"
3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32-
"k8s.io/utils/ptr"
3332
)
3433

3534
var _ = Describe("Node Controller", func() {
@@ -83,7 +82,7 @@ var _ = Describe("Node Controller", func() {
8382
It("successfully get the instance when provider ID not there", func() {
8483
nodeMockClient.EXPECT().ListServers(gomock.Any(), projectID, region).Return(&[]iaas.Server{
8584
{
86-
Name: ptr.To("foo"),
85+
Name: new("foo"),
8786
},
8887
}, nil)
8988

@@ -98,7 +97,7 @@ var _ = Describe("Node Controller", func() {
9897

9998
It("successfully get the instance when provider ID is there", func() {
10099
nodeMockClient.EXPECT().GetServer(gomock.Any(), projectID, region, serverID).Return(&iaas.Server{
101-
Name: ptr.To("foo"),
100+
Name: new("foo"),
102101
}, nil)
103102

104103
node := &corev1.Node{
@@ -115,7 +114,7 @@ var _ = Describe("Node Controller", func() {
115114

116115
It("successfully get the instance when old provider ID is there", func() {
117116
nodeMockClient.EXPECT().GetServer(gomock.Any(), projectID, region, serverID).Return(&iaas.Server{
118-
Name: ptr.To("foo"),
117+
Name: new("foo"),
119118
}, nil)
120119

121120
node := &corev1.Node{
@@ -132,7 +131,7 @@ var _ = Describe("Node Controller", func() {
132131

133132
It("successfully get the instance when old regional provider ID is there", func() {
134133
nodeMockClient.EXPECT().GetServer(gomock.Any(), projectID, region, serverID).Return(&iaas.Server{
135-
Name: ptr.To("foo"),
134+
Name: new("foo"),
136135
}, nil)
137136

138137
node := &corev1.Node{
@@ -178,8 +177,8 @@ var _ = Describe("Node Controller", func() {
178177
It("successfully gets the instance status with provider ID", func() {
179178
nodeMockClient.EXPECT().ListServers(gomock.Any(), projectID, region).Return(&[]iaas.Server{
180179
{
181-
Name: ptr.To("foo"),
182-
Status: ptr.To(instanceStopping),
180+
Name: new("foo"),
181+
Status: new(instanceStopping),
183182
},
184183
}, nil)
185184

@@ -194,8 +193,8 @@ var _ = Describe("Node Controller", func() {
194193

195194
It("successfully gets the instance status without provider ID", func() {
196195
nodeMockClient.EXPECT().GetServer(gomock.Any(), projectID, region, serverID).Return(&iaas.Server{
197-
Name: ptr.To("foo"),
198-
Status: ptr.To("ACTIVE"),
196+
Name: new("foo"),
197+
Status: new("ACTIVE"),
199198
}, nil)
200199

201200
node := &corev1.Node{
@@ -239,12 +238,12 @@ var _ = Describe("Node Controller", func() {
239238
It("successfully get all the metadata values", func() {
240239
nodeMockClient.EXPECT().ListServers(gomock.Any(), projectID, region).Return(&[]iaas.Server{
241240
{
242-
Name: ptr.To("foo"),
243-
Id: ptr.To(serverID),
244-
MachineType: ptr.To("flatcar"),
241+
Name: new("foo"),
242+
Id: new(serverID),
243+
MachineType: new("flatcar"),
245244
Nics: &[]iaas.ServerNetwork{
246245
{
247-
Ipv4: ptr.To("10.10.100.24"),
246+
Ipv4: new("10.10.100.24"),
248247
},
249248
},
250249
},

pkg/ccm/loadbalancer.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"k8s.io/client-go/tools/record"
1313
cloudprovider "k8s.io/cloud-provider"
1414
"k8s.io/cloud-provider/api"
15-
"k8s.io/utils/ptr"
1615

1716
"github.com/stackitcloud/cloud-provider-stackit/pkg/cmp"
1817
"github.com/stackitcloud/cloud-provider-stackit/pkg/stackit"
@@ -215,7 +214,7 @@ func (l *LoadBalancer) createLoadBalancer(ctx context.Context, clusterName strin
215214
return nil, fmt.Errorf("invalid load balancer specification: %w", err)
216215
}
217216
if l.opts.ExtraLabels != nil {
218-
spec.Labels = ptr.To(l.opts.ExtraLabels)
217+
spec.Labels = new(l.opts.ExtraLabels)
219218
}
220219
for _, event := range events {
221220
l.recorder.Event(service, event.Type, event.Reason, event.Message)
@@ -433,7 +432,7 @@ func loadBalancerStatus(lb *loadbalancer.LoadBalancer, svc *corev1.Service) *cor
433432
if ip != nil {
434433
ingress := corev1.LoadBalancerIngress{IP: *ip}
435434
if ipModeProxy, _ := strconv.ParseBool(svc.Annotations[ipModeProxyAnnotation]); ipModeProxy {
436-
ingress.IPMode = ptr.To(corev1.LoadBalancerIPModeProxy)
435+
ingress.IPMode = new(corev1.LoadBalancerIPModeProxy)
437436
}
438437
ingresses = []corev1.LoadBalancerIngress{ingress}
439438
}

pkg/ccm/loadbalancer_spec.go

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ package ccm
33
import (
44
"fmt"
55
"net/netip"
6+
"slices"
67
"strconv"
78
"strings"
89
"time"
910

10-
"github.com/stackitcloud/stackit-sdk-go/core/utils"
1111
"github.com/stackitcloud/stackit-sdk-go/services/loadbalancer"
1212
corev1 "k8s.io/api/core/v1"
13-
"k8s.io/utils/ptr"
1413

1514
"github.com/stackitcloud/cloud-provider-stackit/pkg/cmp"
1615
)
@@ -216,10 +215,8 @@ func proxyProtocolEnableForPort(tcpProxyProtocolEnabled bool, tcpProxyProtocolPo
216215
func getPlanID(service *corev1.Service) (planID *string, msgs []string, err error) {
217216
msgs = make([]string, 0)
218217
if planID, found := service.Annotations[servicePlanAnnotation]; found {
219-
for _, availablePlan := range availablePlanIDs {
220-
if planID == availablePlan {
221-
return &planID, nil, nil
222-
}
218+
if slices.Contains(availablePlanIDs, planID) {
219+
return &planID, nil, nil
223220
}
224221
return nil, nil, fmt.Errorf("unsupported plan ID value %q, supported values are %v", planID, availablePlanIDs)
225222
}
@@ -251,7 +248,7 @@ func lbSpecFromService( //nolint:funlen,gocyclo // It is long but not complex.
251248
Options: &loadbalancer.LoadBalancerOptions{},
252249
Networks: &[]loadbalancer.Network{
253250
{
254-
Role: utils.Ptr(loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS),
251+
Role: new(loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS),
255252
NetworkId: &opts.NetworkID,
256253
},
257254
},
@@ -260,25 +257,25 @@ func lbSpecFromService( //nolint:funlen,gocyclo // It is long but not complex.
260257
if listenerNetwork := service.Annotations[listenerNetworkAnnotation]; listenerNetwork != "" {
261258
lb.Networks = &[]loadbalancer.Network{
262259
{
263-
Role: utils.Ptr(loadbalancer.NETWORKROLE_TARGETS),
260+
Role: new(loadbalancer.NETWORKROLE_TARGETS),
264261
NetworkId: &opts.NetworkID,
265262
}, {
266-
Role: utils.Ptr(loadbalancer.NETWORKROLE_LISTENERS),
263+
Role: new(loadbalancer.NETWORKROLE_LISTENERS),
267264
NetworkId: &listenerNetwork,
268265
},
269266
}
270267
} else {
271268
lb.Networks = &[]loadbalancer.Network{
272269
{
273-
Role: utils.Ptr(loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS),
270+
Role: new(loadbalancer.NETWORKROLE_LISTENERS_AND_TARGETS),
274271
NetworkId: &opts.NetworkID,
275272
},
276273
}
277274
}
278275

279276
// Add extraLabels if set
280277
if opts.ExtraLabels != nil {
281-
lb.Labels = ptr.To(opts.ExtraLabels)
278+
lb.Labels = new(opts.ExtraLabels)
282279
}
283280

284281
// Add metric metricsRemoteWrite settings
@@ -288,7 +285,7 @@ func lbSpecFromService( //nolint:funlen,gocyclo // It is long but not complex.
288285

289286
// Parse private network from annotations.
290287
// TODO: Split into separate function.
291-
lb.Options.PrivateNetworkOnly = utils.Ptr(false)
288+
lb.Options.PrivateNetworkOnly = new(false)
292289
var internal *bool
293290
var yawolInternal *bool
294291
if internalStr, found := service.Annotations[internalLBAnnotation]; found {
@@ -333,9 +330,9 @@ func lbSpecFromService( //nolint:funlen,gocyclo // It is long but not complex.
333330
"incompatible values for annotations %s and %s", yawolExistingFloatingIPAnnotation, externalIPAnnotation,
334331
)
335332
}
336-
lb.Options.EphemeralAddress = utils.Ptr(false)
333+
lb.Options.EphemeralAddress = new(false)
337334
if !found && !yawolFound && !*lb.Options.PrivateNetworkOnly {
338-
lb.Options.EphemeralAddress = utils.Ptr(true)
335+
lb.Options.EphemeralAddress = new(true)
339336
}
340337
if !found && yawolFound {
341338
externalIP = yawolExternalIP
@@ -507,32 +504,32 @@ func lbSpecFromService( //nolint:funlen,gocyclo // It is long but not complex.
507504
protocol = loadbalancer.LISTENERPROTOCOL_TCP
508505
}
509506
tcpOptions = &loadbalancer.OptionsTCP{
510-
IdleTimeout: utils.Ptr(fmt.Sprintf("%.0fs", tcpIdleTimeout.Seconds())),
507+
IdleTimeout: new(fmt.Sprintf("%.0fs", tcpIdleTimeout.Seconds())),
511508
}
512509
case corev1.ProtocolUDP:
513510
protocol = loadbalancer.LISTENERPROTOCOL_UDP
514511
udpOptions = &loadbalancer.OptionsUDP{
515-
IdleTimeout: utils.Ptr(fmt.Sprintf("%.0fs", udpIdleTimeout.Seconds())),
512+
IdleTimeout: new(fmt.Sprintf("%.0fs", udpIdleTimeout.Seconds())),
516513
}
517514
default:
518515
return nil, nil, fmt.Errorf("unsupported protocol %q for port %q", port.Protocol, port.Name)
519516
}
520517

521518
listeners = append(listeners, loadbalancer.Listener{
522519
DisplayName: &name,
523-
Port: utils.Ptr(int64(port.Port)),
520+
Port: new(int64(port.Port)),
524521
TargetPool: &name,
525-
Protocol: utils.Ptr(protocol),
522+
Protocol: new(protocol),
526523
Tcp: tcpOptions,
527524
Udp: udpOptions,
528525
})
529526

530527
targetPools = append(targetPools, loadbalancer.TargetPool{
531528
Name: &name,
532-
TargetPort: utils.Ptr(int64(port.NodePort)),
529+
TargetPort: new(int64(port.NodePort)),
533530
Targets: &targets,
534531
SessionPersistence: &loadbalancer.SessionPersistence{
535-
UseSourceIpAddress: utils.Ptr(useSourceIP),
532+
UseSourceIpAddress: new(useSourceIP),
536533
},
537534
})
538535
}

0 commit comments

Comments
 (0)