Skip to content

Commit a1f28eb

Browse files
authored
chore: update to go 1.26 (#132)
1 parent fd660fe commit a1f28eb

15 files changed

Lines changed: 89 additions & 105 deletions

File tree

.golangci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ linters:
5555
- nolintlint
5656
- nosprintfhostport
5757
- perfsprint
58-
- prealloc
5958
- predeclared
6059
- recvcheck
6160
- revive

api/v1alpha1/webhook/hostedcontrolplane_webhook_test.go

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
. "github.com/teutonet/cluster-api-provider-hosted-control-plane/test"
1111
"k8s.io/apimachinery/pkg/api/resource"
1212
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13-
"k8s.io/utils/ptr"
1413
)
1514

1615
func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
@@ -31,14 +30,14 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
3130
},
3231
Spec: v1alpha1.HostedControlPlaneSpec{
3332
Version: "v1.28.0",
34-
Replicas: ptr.To[int32](3),
33+
Replicas: new(int32(3)),
3534
HostedControlPlaneInlineSpec: v1alpha1.HostedControlPlaneInlineSpec{
3635
Gateway: v1alpha1.GatewayReference{
3736
Name: "test-gateway",
3837
Namespace: "default",
3938
},
4039
ETCD: v1alpha1.ETCDComponent{
41-
AutoGrow: ptr.To(true),
40+
AutoGrow: new(true),
4241
},
4342
},
4443
},
@@ -54,15 +53,15 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
5453
},
5554
Spec: v1alpha1.HostedControlPlaneSpec{
5655
Version: "1.28.0",
57-
Replicas: ptr.To[int32](1),
56+
Replicas: new(int32(1)),
5857
HostedControlPlaneInlineSpec: v1alpha1.HostedControlPlaneInlineSpec{
5958
Gateway: v1alpha1.GatewayReference{
6059
Name: "test-gateway",
6160
Namespace: "default",
6261
},
6362
ETCD: v1alpha1.ETCDComponent{
64-
AutoGrow: ptr.To(false),
65-
VolumeSize: ptr.To(resource.MustParse("20Gi")),
63+
AutoGrow: new(false),
64+
VolumeSize: new(resource.MustParse("20Gi")),
6665
},
6766
},
6867
},
@@ -84,7 +83,7 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
8483
Namespace: "default",
8584
},
8685
ETCD: v1alpha1.ETCDComponent{
87-
AutoGrow: ptr.To(true),
86+
AutoGrow: new(true),
8887
},
8988
},
9089
},
@@ -107,8 +106,8 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
107106
Namespace: "default",
108107
},
109108
ETCD: v1alpha1.ETCDComponent{
110-
AutoGrow: ptr.To(true),
111-
VolumeSize: ptr.To(resource.MustParse("20Gi")),
109+
AutoGrow: new(true),
110+
VolumeSize: new(resource.MustParse("20Gi")),
112111
},
113112
},
114113
},
@@ -131,7 +130,7 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
131130
Namespace: "default",
132131
},
133132
ETCD: v1alpha1.ETCDComponent{
134-
AutoGrow: ptr.To(false),
133+
AutoGrow: new(false),
135134
},
136135
},
137136
},
@@ -147,7 +146,7 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
147146
Version: "v1.28.0",
148147
HostedControlPlaneInlineSpec: v1alpha1.HostedControlPlaneInlineSpec{
149148
Gateway: v1alpha1.GatewayReference{Name: "test-gateway", Namespace: "default"},
150-
ETCD: v1alpha1.ETCDComponent{AutoGrow: ptr.To(true)},
149+
ETCD: v1alpha1.ETCDComponent{AutoGrow: new(true)},
151150
OIDCProviders: map[string]v1alpha1.OIDCProvider{
152151
importcycle.LocalClusterOIDCEndpoint: {
153152
Audiences: []string{"my-app"},
@@ -170,7 +169,7 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
170169
Version: "v1.28.0",
171170
HostedControlPlaneInlineSpec: v1alpha1.HostedControlPlaneInlineSpec{
172171
Gateway: v1alpha1.GatewayReference{Name: "test-gateway", Namespace: "default"},
173-
ETCD: v1alpha1.ETCDComponent{AutoGrow: ptr.To(true)},
172+
ETCD: v1alpha1.ETCDComponent{AutoGrow: new(true)},
174173
OIDCProviders: map[string]v1alpha1.OIDCProvider{
175174
"https://oidc.example.com": {
176175
Audiences: []string{"my-app"},
@@ -192,7 +191,7 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
192191
Version: "v1.28.0",
193192
HostedControlPlaneInlineSpec: v1alpha1.HostedControlPlaneInlineSpec{
194193
Gateway: v1alpha1.GatewayReference{Name: "test-gateway", Namespace: "default"},
195-
ETCD: v1alpha1.ETCDComponent{AutoGrow: ptr.To(true)},
194+
ETCD: v1alpha1.ETCDComponent{AutoGrow: new(true)},
196195
Certificates: v1alpha1.CertificatesSpec{
197196
RootCACertificateDuration: &metav1.Duration{Duration: 10 * 365 * 24 * time.Hour},
198197
CACertificateDuration: &metav1.Duration{Duration: 5 * 365 * 24 * time.Hour},
@@ -210,7 +209,7 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
210209
Version: "v1.28.0",
211210
HostedControlPlaneInlineSpec: v1alpha1.HostedControlPlaneInlineSpec{
212211
Gateway: v1alpha1.GatewayReference{Name: "test-gateway", Namespace: "default"},
213-
ETCD: v1alpha1.ETCDComponent{AutoGrow: ptr.To(true)},
212+
ETCD: v1alpha1.ETCDComponent{AutoGrow: new(true)},
214213
Certificates: v1alpha1.CertificatesSpec{
215214
RootCACertificateDuration: &metav1.Duration{Duration: 5 * 365 * 24 * time.Hour},
216215
CACertificateDuration: &metav1.Duration{Duration: 5 * 365 * 24 * time.Hour},
@@ -228,7 +227,7 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
228227
Version: "v1.28.0",
229228
HostedControlPlaneInlineSpec: v1alpha1.HostedControlPlaneInlineSpec{
230229
Gateway: v1alpha1.GatewayReference{Name: "test-gateway", Namespace: "default"},
231-
ETCD: v1alpha1.ETCDComponent{AutoGrow: ptr.To(true)},
230+
ETCD: v1alpha1.ETCDComponent{AutoGrow: new(true)},
232231
Certificates: v1alpha1.CertificatesSpec{
233232
RootCACertificateDuration: &metav1.Duration{Duration: 1 * 365 * 24 * time.Hour},
234233
CACertificateDuration: &metav1.Duration{Duration: 5 * 365 * 24 * time.Hour},
@@ -247,7 +246,7 @@ func TestHostedControlPlaneWebhook_ValidateCreate(t *testing.T) {
247246
Version: "v1.28.0",
248247
HostedControlPlaneInlineSpec: v1alpha1.HostedControlPlaneInlineSpec{
249248
Gateway: v1alpha1.GatewayReference{Name: "test-gateway", Namespace: "default"},
250-
ETCD: v1alpha1.ETCDComponent{AutoGrow: ptr.To(true)},
249+
ETCD: v1alpha1.ETCDComponent{AutoGrow: new(true)},
251250
Certificates: v1alpha1.CertificatesSpec{
252251
RootCACertificateDuration: &metav1.Duration{Duration: 24 * time.Hour},
253252
},
@@ -290,14 +289,14 @@ func TestHostedControlPlaneWebhook_ValidateUpdate(t *testing.T) {
290289
Namespace: "default",
291290
},
292291
ETCD: v1alpha1.ETCDComponent{
293-
AutoGrow: ptr.To(autoGrow),
292+
AutoGrow: new(autoGrow),
294293
},
295294
},
296295
},
297296
}
298297

299298
if volumeSize != "" {
300-
hcp.Spec.ETCD.VolumeSize = ptr.To(resource.MustParse(volumeSize))
299+
hcp.Spec.ETCD.VolumeSize = new(resource.MustParse(volumeSize))
301300
}
302301

303302
return hcp

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/teutonet/cluster-api-provider-hosted-control-plane
22

3-
go 1.25.7
3+
go 1.26.3
44

55
require (
66
github.com/aws/aws-sdk-go-v2 v1.41.5

pkg/hostedcontrolplane/controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import (
4545
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4646
"k8s.io/client-go/tools/events"
4747
utilNet "k8s.io/utils/net"
48-
"k8s.io/utils/ptr"
4948
capiv2 "sigs.k8s.io/cluster-api/api/core/v1beta2"
5049
"sigs.k8s.io/cluster-api/util"
5150
"sigs.k8s.io/cluster-api/util/conditions"
@@ -379,7 +378,7 @@ func (r *hostedControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.R
379378
return ctrl.Result{}, fmt.Errorf("failed to create patch helper for HostedControlPlane: %w", err)
380379
}
381380

382-
hostedControlPlane.Status.ExternalManagedControlPlane = ptr.To(true)
381+
hostedControlPlane.Status.ExternalManagedControlPlane = new(true)
383382

384383
ctx = recorder.IntoContext(ctx, recorder.New(r.recorder, hostedControlPlane))
385384

pkg/hostedcontrolplane/controller_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"k8s.io/apimachinery/pkg/runtime"
2020
"k8s.io/apimachinery/pkg/types"
2121
"k8s.io/client-go/kubernetes/fake"
22-
"k8s.io/utils/ptr"
2322
capiv2 "sigs.k8s.io/cluster-api/api/core/v1beta2"
2423
ctrl "sigs.k8s.io/controller-runtime"
2524
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -121,7 +120,7 @@ func withPausedCondition(cluster *capiv2.Cluster, paused bool) *capiv2.Cluster {
121120

122121
func withPaused(cluster *capiv2.Cluster, paused bool) *capiv2.Cluster {
123122
newCluster := cluster.DeepCopy()
124-
newCluster.Spec.Paused = ptr.To(paused)
123+
newCluster.Spec.Paused = new(paused)
125124
return newCluster
126125
}
127126

@@ -155,7 +154,7 @@ func withOwnerReference(hcp *v1alpha1.HostedControlPlane, cluster *capiv2.Cluste
155154

156155
func withReplicas(hcp *v1alpha1.HostedControlPlane, replicas int32) *v1alpha1.HostedControlPlane {
157156
newHCP := hcp.DeepCopy()
158-
newHCP.Spec.Replicas = ptr.To(replicas)
157+
newHCP.Spec.Replicas = new(replicas)
159158
return newHCP
160159
}
161160

@@ -167,8 +166,7 @@ func withConditions(hcp *v1alpha1.HostedControlPlane, conditions []metav1.Condit
167166

168167
func withDeletion(hcp *v1alpha1.HostedControlPlane, finalizers []string) *v1alpha1.HostedControlPlane {
169168
newHCP := hcp.DeepCopy()
170-
now := metav1.Now()
171-
newHCP.DeletionTimestamp = &now
169+
newHCP.DeletionTimestamp = new(metav1.Now())
172170
newHCP.Finalizers = finalizers
173171
return newHCP
174172
}

pkg/hostedcontrolplane/lifecycle_phases_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import (
4343
"k8s.io/cluster-bootstrap/token/api"
4444
konstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
4545
"k8s.io/kubernetes/pkg/controller/certificates/rootcacertpublisher"
46-
"k8s.io/utils/ptr"
4746
capiv2 "sigs.k8s.io/cluster-api/api/core/v1beta2"
4847
"sigs.k8s.io/cluster-api/util/conditions"
4948
"sigs.k8s.io/cluster-api/util/contract"
@@ -191,8 +190,8 @@ func TestHostedControlPlane_FullLifecycle(t *testing.T) {
191190
Name: "test-gateway",
192191
},
193192
ETCD: v1alpha1.ETCDComponent{
194-
AutoGrow: ptr.To(false),
195-
VolumeSize: ptr.To(resource.MustParse("1Gi")),
193+
AutoGrow: new(false),
194+
VolumeSize: new(resource.MustParse("1Gi")),
196195
},
197196
},
198197
},
@@ -211,7 +210,7 @@ func TestHostedControlPlane_FullLifecycle(t *testing.T) {
211210
Name: "tls",
212211
Protocol: gwv1.TLSProtocolType,
213212
Port: 443,
214-
Hostname: ptr.To(gwv1.Hostname("*.example.com")),
213+
Hostname: new(gwv1.Hostname("*.example.com")),
215214
},
216215
},
217216
},
@@ -1120,7 +1119,7 @@ func TestHostedControlPlane_FullLifecycle(t *testing.T) {
11201119
{
11211120
name: "Scale Up to 3 Replicas",
11221121
patchHCP: func() {
1123-
hcp.Spec.Replicas = ptr.To(int32(3))
1122+
hcp.Spec.Replicas = new(int32(3))
11241123
},
11251124
verifyResources: func(ctx context.Context, g Gomega) {
11261125
deploymentInterface := managementClusterClient.AppsV1().Deployments(hcp.Namespace)
@@ -1159,7 +1158,7 @@ func TestHostedControlPlane_FullLifecycle(t *testing.T) {
11591158
{
11601159
name: "Scale Up ETCD storage",
11611160
patchHCP: func() {
1162-
hcp.Spec.ETCD.VolumeSize = ptr.To(resource.MustParse("2Gi"))
1161+
hcp.Spec.ETCD.VolumeSize = new(resource.MustParse("2Gi"))
11631162
},
11641163
verifyResources: func(ctx context.Context, g Gomega) {
11651164
statefulSet, err := managementClusterClient.AppsV1().StatefulSets(hcp.Namespace).Get(
@@ -1194,13 +1193,13 @@ func TestHostedControlPlane_FullLifecycle(t *testing.T) {
11941193
name: "Switch from Custom Etcd volume size to autogrow",
11951194
patchHCP: func() {
11961195
hcp.Spec.ETCD.VolumeSize = nil
1197-
hcp.Spec.ETCD.AutoGrow = ptr.To(true)
1196+
hcp.Spec.ETCD.AutoGrow = new(true)
11981197
},
11991198
},
12001199
{
12011200
name: "Let Etcd grow",
12021201
simulateExternalSystems: func(ctx context.Context, g Gomega) {
1203-
volumeStatsStub.MaxUsage = ptr.To(resource.MustParse("1.5Gi")).Value()
1202+
volumeStatsStub.MaxUsage = new(resource.MustParse("1.5Gi")).Value()
12041203
},
12051204
verifyResources: func(ctx context.Context, g Gomega) {
12061205
g.Expect(hcp.Status.ETCDVolumeUsage).To(EqualResource(resource.MustParse("1.5Gi")))

0 commit comments

Comments
 (0)