Skip to content

Commit 99891e8

Browse files
authored
Merge pull request #191 from datum-cloud/ci/golangci-lint-go1.26
CI maintenance: golangci-lint for Go 1.26 + datum-cloud/actions v1.15.0
2 parents 50f2ea4 + 3995fa3 commit 99891e8

55 files changed

Lines changed: 486 additions & 513 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
- name: Setup Go
1616
uses: actions/setup-go@v5
1717
with:
18-
go-version: '~1.24'
18+
go-version: '~1.26'
1919

2020
- name: Run linter
2121
uses: golangci/golangci-lint-action@v7
2222
with:
23-
version: v2.1.6
23+
version: v2.12.2

.github/workflows/publish.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
contents: read
1717
packages: write
1818
attestations: write
19-
uses: datum-cloud/actions/.github/workflows/publish-docker.yaml@v1.14.0
19+
uses: datum-cloud/actions/.github/workflows/publish-docker.yaml@v1.15.0
2020
with:
2121
image-name: network-services-operator
2222
platforms: linux/amd64,linux/arm64
@@ -27,7 +27,7 @@ jobs:
2727
id-token: write
2828
contents: read
2929
packages: write
30-
uses: datum-cloud/actions/.github/workflows/publish-kustomize-bundle.yaml@v1.14.0
30+
uses: datum-cloud/actions/.github/workflows/publish-kustomize-bundle.yaml@v1.15.0
3131
with:
3232
bundle-name: ghcr.io/datum-cloud/network-services-operator-kustomize
3333
bundle-path: config

.github/workflows/validate-kustomize.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ on:
55

66
jobs:
77
validate-kustomize:
8-
uses: datum-cloud/actions/.github/workflows/validate-kustomize.yaml@v1.6.1
8+
uses: datum-cloud/actions/.github/workflows/validate-kustomize.yaml@v1.15.0

.golangci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ linters:
3737
- dupl
3838
- lll
3939
path: internal/*
40+
# Repeated string literals in tests are usually fixture/table data;
41+
# extracting them to constants hurts readability more than it helps.
42+
- linters:
43+
- goconst
44+
path: _test\.go
45+
# The validation packages are built almost entirely from field.ErrorList
46+
# accumulators that hold a handful of errors; preallocating them adds noise
47+
# without meaningful benefit.
48+
- linters:
49+
- prealloc
50+
path: internal/validation
4051
paths:
4152
- third_party$
4253
- builtin$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ KUSTOMIZE_VERSION ?= v5.5.0
241241
CONTROLLER_TOOLS_VERSION ?= v0.16.4
242242
DEFAULTER_GEN_VERSION ?= v0.32.3
243243
ENVTEST_VERSION ?= release-0.19
244-
GOLANGCI_LINT_VERSION ?= v2.1.6
244+
GOLANGCI_LINT_VERSION ?= v2.12.2
245245

246246
# renovate: datasource=go depName=github.com/cert-manager/cert-manager
247247
CERTMANAGER_VERSION ?= 1.17.1

api/v1alpha/domain_types.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,3 @@ type DomainList struct {
229229
metav1.ListMeta `json:"metadata,omitempty"`
230230
Items []Domain `json:"items"`
231231
}
232-
233-
func init() {
234-
SchemeBuilder.Register(&Domain{}, &DomainList{})
235-
}

api/v1alpha/groupversion_info.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,47 @@
66
package v1alpha
77

88
import (
9+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
10+
"k8s.io/apimachinery/pkg/runtime"
911
"k8s.io/apimachinery/pkg/runtime/schema"
10-
"sigs.k8s.io/controller-runtime/pkg/scheme"
1112
)
1213

1314
var (
1415
// GroupVersion is group version used to register these objects.
1516
GroupVersion = schema.GroupVersion{Group: "networking.datumapis.com", Version: "v1alpha"}
1617

1718
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
18-
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
19+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
1920

2021
// AddToScheme adds the types in this group-version to the given scheme.
2122
AddToScheme = SchemeBuilder.AddToScheme
2223
)
24+
25+
func addKnownTypes(scheme *runtime.Scheme) error {
26+
scheme.AddKnownTypes(GroupVersion,
27+
&Domain{},
28+
&DomainList{},
29+
&HTTPProxy{},
30+
&HTTPProxyList{},
31+
&Location{},
32+
&LocationList{},
33+
&LocationBinding{},
34+
&LocationBindingList{},
35+
&Network{},
36+
&NetworkList{},
37+
&NetworkBinding{},
38+
&NetworkBindingList{},
39+
&NetworkContext{},
40+
&NetworkContextList{},
41+
&NetworkPolicy{},
42+
&NetworkPolicyList{},
43+
&Subnet{},
44+
&SubnetList{},
45+
&SubnetClaim{},
46+
&SubnetClaimList{},
47+
&TrafficProtectionPolicy{},
48+
&TrafficProtectionPolicyList{},
49+
)
50+
metav1.AddToGroupVersion(scheme, GroupVersion)
51+
return nil
52+
}

api/v1alpha/httpproxy_types.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,3 @@ type HTTPProxyList struct {
459459
metav1.ListMeta `json:"metadata,omitempty"`
460460
Items []HTTPProxy `json:"items"`
461461
}
462-
463-
func init() {
464-
SchemeBuilder.Register(&HTTPProxy{}, &HTTPProxyList{})
465-
}

api/v1alpha/httpproxy_types_test.go

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ import (
1414
networkingv1alpha "go.datum.net/network-services-operator/api/v1alpha"
1515
)
1616

17-
const testMutatedHostname = "mutated.example.com"
17+
const (
18+
testMutatedHostname = "mutated.example.com"
19+
testAPIHostname = "api.example.com"
20+
testCanonicalGatewayHostname = "abc123.gateways.test.local"
21+
)
1822

1923
// TestHostnameStatus_DeepCopy verifies that DeepCopy produces an independent
2024
// copy of a HostnameStatus value with all nested slices properly duplicated.
2125
func TestHostnameStatus_DeepCopy(t *testing.T) {
2226
t.Parallel()
2327

2428
original := networkingv1alpha.HostnameStatus{
25-
Hostname: "api.example.com",
29+
Hostname: testAPIHostname,
2630
Conditions: []metav1.Condition{
2731
{
2832
Type: networkingv1alpha.HostnameConditionDNSRecordProgrammed,
@@ -52,7 +56,7 @@ func TestHostnameStatus_DeepCopy(t *testing.T) {
5256
copied.Conditions[0].Message = "mutated message"
5357
copied.Conditions = append(copied.Conditions, metav1.Condition{Type: "Extra"})
5458

55-
assert.Equal(t, "api.example.com", original.Hostname)
59+
assert.Equal(t, testAPIHostname, original.Hostname)
5660
assert.Equal(t, "cname record created in DNSZone \"example-com\"", original.Conditions[0].Message)
5761
assert.Len(t, original.Conditions, 2, "original conditions should not gain extra element")
5862
}
@@ -87,11 +91,11 @@ func TestHTTPProxyStatus_DeepCopy(t *testing.T) {
8791
t.Parallel()
8892

8993
original := networkingv1alpha.HTTPProxyStatus{
90-
CanonicalHostname: "abc123.gateways.test.local",
94+
CanonicalHostname: testCanonicalGatewayHostname,
9195
Addresses: []gatewayv1.GatewayStatusAddress{
9296
{
9397
Type: ptr.To(gatewayv1.HostnameAddressType),
94-
Value: "abc123.gateways.test.local",
98+
Value: testCanonicalGatewayHostname,
9599
},
96100
{
97101
Type: ptr.To(gatewayv1.IPAddressType),
@@ -100,7 +104,7 @@ func TestHTTPProxyStatus_DeepCopy(t *testing.T) {
100104
},
101105
HostnameStatuses: []networkingv1alpha.HostnameStatus{
102106
{
103-
Hostname: "api.example.com",
107+
Hostname: testAPIHostname,
104108
Conditions: []metav1.Condition{
105109
{
106110
Type: networkingv1alpha.HostnameConditionDNSRecordProgrammed,
@@ -130,11 +134,11 @@ func TestHTTPProxyStatus_DeepCopy(t *testing.T) {
130134

131135
// Mutation independence – addresses.
132136
copied.Addresses[0].Value = "mutated"
133-
assert.Equal(t, "abc123.gateways.test.local", original.Addresses[0].Value)
137+
assert.Equal(t, testCanonicalGatewayHostname, original.Addresses[0].Value)
134138

135139
// Mutation independence – hostname statuses.
136140
copied.HostnameStatuses[0].Hostname = testMutatedHostname
137-
assert.Equal(t, "api.example.com", original.HostnameStatuses[0].Hostname)
141+
assert.Equal(t, testAPIHostname, original.HostnameStatuses[0].Hostname)
138142

139143
// Mutation independence – conditions.
140144
copied.Conditions[0].Reason = "Mutated"
@@ -161,13 +165,13 @@ func TestHTTPProxy_DeepCopy(t *testing.T) {
161165
Namespace: "default",
162166
},
163167
Spec: networkingv1alpha.HTTPProxySpec{
164-
Hostnames: []gatewayv1.Hostname{"api.example.com", "example.com"},
168+
Hostnames: []gatewayv1.Hostname{testAPIHostname, "example.com"},
165169
},
166170
Status: networkingv1alpha.HTTPProxyStatus{
167-
CanonicalHostname: "abc123.gateways.test.local",
171+
CanonicalHostname: testCanonicalGatewayHostname,
168172
HostnameStatuses: []networkingv1alpha.HostnameStatus{
169173
{
170-
Hostname: "api.example.com",
174+
Hostname: testAPIHostname,
171175
Conditions: []metav1.Condition{
172176
{
173177
Type: networkingv1alpha.HostnameConditionDNSRecordProgrammed,
@@ -192,13 +196,13 @@ func TestHTTPProxy_DeepCopy(t *testing.T) {
192196

193197
// Mutation independence.
194198
copied.Status.CanonicalHostname = "mutated"
195-
assert.Equal(t, "abc123.gateways.test.local", original.Status.CanonicalHostname)
199+
assert.Equal(t, testCanonicalGatewayHostname, original.Status.CanonicalHostname)
196200

197201
copied.Status.HostnameStatuses[0].Hostname = testMutatedHostname
198-
assert.Equal(t, "api.example.com", original.Status.HostnameStatuses[0].Hostname)
202+
assert.Equal(t, testAPIHostname, original.Status.HostnameStatuses[0].Hostname)
199203

200204
copied.Spec.Hostnames[0] = testMutatedHostname
201-
assert.Equal(t, gatewayv1.Hostname("api.example.com"), original.Spec.Hostnames[0])
205+
assert.Equal(t, gatewayv1.Hostname(testAPIHostname), original.Spec.Hostnames[0])
202206
}
203207

204208
// TestConditionConstants verifies that the expected condition constant strings

api/v1alpha/location_types.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,3 @@ type LocationReference struct {
106106
// +kubebuilder:validation:Required
107107
Namespace string `json:"namespace"`
108108
}
109-
110-
func init() {
111-
SchemeBuilder.Register(&Location{}, &LocationList{})
112-
}

0 commit comments

Comments
 (0)