Skip to content

Commit 9ace21c

Browse files
Merge pull request #242 from numtide/chore/upgrade-golangci-lint-and-restructure-ci
chore(ci): upgrade golangci-lint to v2.9.0 and drop lint from release pipeline
2 parents 1cd8703 + 0e13920 commit 9ace21c

30 files changed

+516
-135
lines changed

.github/workflows/build-and-release.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,11 @@ jobs:
4444
with:
4545
go-version-file: ${{ matrix.module }}/go.mod
4646

47-
- name: Run linter
48-
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
49-
with:
50-
working-directory: ${{ matrix.module }}
51-
args: --config=${{ github.workspace }}/.golangci.toml
52-
5347
- name: Run tests
5448
run: |-
5549
cd ${{ matrix.module}}
5650
go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...
5751
58-
# - name: Check test coverage
59-
# uses: vladopajic/go-test-coverage@cc5012c2cfa84542e02b079141958a885861d326 # v2.17.0
60-
# with:
61-
# config: ${{ matrix.module }}/.testcoverage.yml
6252
6353
build-scan-push-container:
6454
needs: [ test-go ]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ KUSTOMIZE_VERSION ?= v5.6.0
112112
# renovate: datasource=github-releases depName=kubernetes-sigs/controller-tools
113113
CONTROLLER_TOOLS_VERSION ?= v0.18.0
114114
# renovate: datasource=github-releases depName=golangci/golangci-lint
115-
GOLANGCI_LINT_VERSION ?= v2.3.0
115+
GOLANGCI_LINT_VERSION ?= v2.9.0
116116

117117
CERT_MANAGER_VERSION ?= v1.19.2
118118

cmd/multigres-operator/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ func main() {
225225
)
226226
useInternalCerts = true
227227
} else {
228-
setupLog.Info("webhook certificates found on disk; using external certificate management")
228+
setupLog.Info(
229+
"webhook certificates found on disk; using external certificate management",
230+
)
229231
}
230232
}
231233

pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ func (r *MultigresClusterReconciler) Reconcile(
7777
// Bridge the async webhook → reconcile trace gap.
7878
// If the webhook injected a traceparent into the cluster's annotations,
7979
// restart the span under that parent context (or link if stale).
80-
if parentCtx, isStale := monitoring.ExtractTraceContext(cluster.GetAnnotations()); trace.SpanFromContext(parentCtx).
80+
if parentCtx, isStale := monitoring.ExtractTraceContext(
81+
cluster.GetAnnotations(),
82+
); trace.SpanFromContext(parentCtx).
8183
SpanContext().
8284
IsValid() {
8385
span.End() // End the initial orphan span.
@@ -86,7 +88,13 @@ func (r *MultigresClusterReconciler) Reconcile(
8688
trace.WithLinks(trace.LinkFromContext(parentCtx)),
8789
)
8890
} else {
89-
ctx, span = monitoring.StartReconcileSpan(parentCtx, "MultigresCluster.Reconcile", req.Name, req.Namespace, "MultigresCluster")
91+
ctx, span = monitoring.StartReconcileSpan(
92+
parentCtx,
93+
"MultigresCluster.Reconcile",
94+
req.Name,
95+
req.Namespace,
96+
"MultigresCluster",
97+
)
9098
}
9199
defer span.End()
92100
ctx = monitoring.EnrichLoggerWithTrace(ctx)

pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller_test.go

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,21 @@ func runReconcileTest(t *testing.T, tests map[string]reconcileTestCase) {
110110

111111
if shouldDelete {
112112
// Simulate deletion workflow
113-
if err := baseClient.Get(t.Context(), types.NamespacedName{Name: cluster.Name, Namespace: cluster.Namespace}, cluster); err != nil {
113+
if err := baseClient.Get(
114+
t.Context(),
115+
types.NamespacedName{Name: cluster.Name, Namespace: cluster.Namespace},
116+
cluster,
117+
); err != nil {
114118
t.Fatalf("failed to refresh cluster before delete: %v", err)
115119
}
116120
if err := baseClient.Delete(t.Context(), cluster); err != nil {
117121
t.Fatalf("failed to set deletion timestamp: %v", err)
118122
}
119-
if err := baseClient.Get(t.Context(), types.NamespacedName{Name: cluster.Name, Namespace: cluster.Namespace}, cluster); err != nil {
123+
if err := baseClient.Get(
124+
t.Context(),
125+
types.NamespacedName{Name: cluster.Name, Namespace: cluster.Namespace},
126+
cluster,
127+
); err != nil {
120128
t.Fatalf("failed to refresh cluster after deletion: %v", err)
121129
}
122130
}
@@ -151,7 +159,11 @@ func runReconcileTest(t *testing.T, tests map[string]reconcileTestCase) {
151159
if err == nil {
152160
t.Error("Expected error from Reconcile, got nil")
153161
} else if !strings.Contains(err.Error(), tc.wantErrMsg) {
154-
t.Errorf("Error mismatch. Expected substring %q, got %q", tc.wantErrMsg, err.Error())
162+
t.Errorf(
163+
"Error mismatch. Expected substring %q, got %q",
164+
tc.wantErrMsg,
165+
err.Error(),
166+
)
155167
}
156168
} else if err != nil {
157169
t.Errorf("Unexpected error from Reconcile: %v", err)
@@ -331,10 +343,16 @@ func TestMultigresClusterReconciler_Lifecycle(t *testing.T) {
331343
clusterName,
332344
"zone-a",
333345
)
334-
if err := c.Get(ctx, types.NamespacedName{Name: cellName, Namespace: namespace}, cell); err != nil {
346+
if err := c.Get(
347+
ctx,
348+
types.NamespacedName{Name: cellName, Namespace: namespace},
349+
cell,
350+
); err != nil {
335351
t.Fatalf("Expected Cell %s to exist: %v", cellName, err)
336352
}
337-
if got, want := cell.Spec.Images.MultiGateway, multigresv1alpha1.ImageRef("gateway:latest"); got != want {
353+
if got, want := cell.Spec.Images.MultiGateway, multigresv1alpha1.ImageRef(
354+
"gateway:latest",
355+
); got != want {
338356
t.Errorf("Cell image mismatch got %q, want %q", got, want)
339357
}
340358
},
@@ -538,7 +556,11 @@ func TestMultigresClusterReconciler_Lifecycle(t *testing.T) {
538556
clusterName,
539557
"zone-a",
540558
)
541-
if err := c.Get(t.Context(), types.NamespacedName{Name: cellName, Namespace: namespace}, cell); err != nil {
559+
if err := c.Get(
560+
t.Context(),
561+
types.NamespacedName{Name: cellName, Namespace: namespace},
562+
cell,
563+
); err != nil {
542564
t.Fatalf("Expected Cell %s to exist: %v", cellName, err)
543565
}
544566
if cell.Spec.GlobalTopoServer.Address != "http://external:2379" {

pkg/cluster-handler/controller/multigrescluster/reconcile_cells.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ func (r *MultigresClusterReconciler) reconcileCells(
1616
res *resolver.Resolver,
1717
) error {
1818
existingCells := &multigresv1alpha1.CellList{}
19-
if err := r.List(ctx, existingCells, client.InNamespace(cluster.Namespace), client.MatchingLabels{"multigres.com/cluster": cluster.Name}); err != nil {
19+
if err := r.List(
20+
ctx,
21+
existingCells,
22+
client.InNamespace(cluster.Namespace),
23+
client.MatchingLabels{"multigres.com/cluster": cluster.Name},
24+
); err != nil {
2025
return fmt.Errorf("failed to list existing cells: %w", err)
2126
}
2227

pkg/cluster-handler/controller/multigrescluster/reconcile_database_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ func TestReconcile_Databases(t *testing.T) {
4040
"default",
4141
)
4242
tg := &multigresv1alpha1.TableGroup{}
43-
if err := c.Get(ctx, types.NamespacedName{Name: tgName, Namespace: namespace}, tg); err != nil {
43+
if err := c.Get(
44+
ctx,
45+
types.NamespacedName{Name: tgName, Namespace: namespace},
46+
tg,
47+
); err != nil {
4448
t.Fatalf("System Catalog TableGroup not found: %v", err)
4549
}
4650

@@ -126,7 +130,11 @@ func TestReconcile_Databases(t *testing.T) {
126130
"db1",
127131
"tg1",
128132
)
129-
if err := c.Get(ctx, types.NamespacedName{Name: tgName, Namespace: namespace}, tg); err != nil {
133+
if err := c.Get(
134+
ctx,
135+
types.NamespacedName{Name: tgName, Namespace: namespace},
136+
tg,
137+
); err != nil {
130138
t.Fatal(err)
131139
}
132140
cells := tg.Spec.Shards[0].MultiOrch.Cells

pkg/cluster-handler/controller/multigrescluster/reconcile_databases.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ func (r *MultigresClusterReconciler) reconcileDatabases(
1616
res *resolver.Resolver,
1717
) error {
1818
existingTGs := &multigresv1alpha1.TableGroupList{}
19-
if err := r.List(ctx, existingTGs, client.InNamespace(cluster.Namespace), client.MatchingLabels{"multigres.com/cluster": cluster.Name}); err != nil {
19+
if err := r.List(
20+
ctx,
21+
existingTGs,
22+
client.InNamespace(cluster.Namespace),
23+
client.MatchingLabels{"multigres.com/cluster": cluster.Name},
24+
); err != nil {
2025
return fmt.Errorf("failed to list existing tablegroups: %w", err)
2126
}
2227

pkg/cluster-handler/controller/multigrescluster/reconcile_global_test.go

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -459,23 +459,40 @@ func TestReconcile_Global(t *testing.T) {
459459
ctx := t.Context()
460460

461461
ts := &multigresv1alpha1.TopoServer{}
462-
if err := c.Get(ctx, types.NamespacedName{Name: clusterName + "-global-topo", Namespace: namespace}, ts); err != nil {
462+
if err := c.Get(
463+
ctx,
464+
types.NamespacedName{Name: clusterName + "-global-topo", Namespace: namespace},
465+
ts,
466+
); err != nil {
463467
t.Fatal(err)
464468
}
465-
if got, want := ts.Spec.Etcd.Image, multigresv1alpha1.ImageRef("etcd:topo"); got != want {
469+
if got, want := ts.Spec.Etcd.Image, multigresv1alpha1.ImageRef(
470+
"etcd:topo",
471+
); got != want {
466472
t.Errorf("TopoServer image mismatch got %q, want %q", got, want)
467473
}
468474

469475
deploy := &appsv1.Deployment{}
470-
if err := c.Get(ctx, types.NamespacedName{Name: clusterName + "-multiadmin", Namespace: namespace}, deploy); err != nil {
476+
if err := c.Get(
477+
ctx,
478+
types.NamespacedName{Name: clusterName + "-multiadmin", Namespace: namespace},
479+
deploy,
480+
); err != nil {
471481
t.Fatal(err)
472482
}
473483
if got, want := *deploy.Spec.Replicas, int32(5); got != want {
474484
t.Errorf("MultiAdmin replicas mismatch got %d, want %d", got, want)
475485
}
476486

477487
webDeploy := &appsv1.Deployment{}
478-
if err := c.Get(ctx, types.NamespacedName{Name: clusterName + "-multiadmin-web", Namespace: namespace}, webDeploy); err != nil {
488+
if err := c.Get(
489+
ctx,
490+
types.NamespacedName{
491+
Name: clusterName + "-multiadmin-web",
492+
Namespace: namespace,
493+
},
494+
webDeploy,
495+
); err != nil {
479496
t.Fatal(err)
480497
}
481498
// Default replicas is 1
@@ -485,7 +502,11 @@ func TestReconcile_Global(t *testing.T) {
485502

486503
// Verify global multigateway Service exists
487504
gwSvc := &corev1.Service{}
488-
if err := c.Get(ctx, types.NamespacedName{Name: clusterName + "-multigateway", Namespace: namespace}, gwSvc); err != nil {
505+
if err := c.Get(
506+
ctx,
507+
types.NamespacedName{Name: clusterName + "-multigateway", Namespace: namespace},
508+
gwSvc,
509+
); err != nil {
489510
t.Fatalf("Expected global multigateway Service to exist: %v", err)
490511
}
491512
if gwSvc.Spec.Selector["app.kubernetes.io/component"] != "multigateway" {
@@ -510,7 +531,11 @@ func TestReconcile_Global(t *testing.T) {
510531
validate: func(t testing.TB, c client.Client) {
511532
ctx := t.Context()
512533
ts := &multigresv1alpha1.TopoServer{}
513-
if err := c.Get(ctx, types.NamespacedName{Name: clusterName + "-global-topo", Namespace: namespace}, ts); err != nil {
534+
if err := c.Get(
535+
ctx,
536+
types.NamespacedName{Name: clusterName + "-global-topo", Namespace: namespace},
537+
ts,
538+
); err != nil {
514539
t.Fatal(err)
515540
}
516541
if got, want := ts.Spec.Etcd.RootPath, "/custom/root"; got != want {
@@ -531,7 +556,11 @@ func TestReconcile_Global(t *testing.T) {
531556
validate: func(t testing.TB, c client.Client) {
532557
ctx := t.Context()
533558
ts := &multigresv1alpha1.TopoServer{}
534-
if err := c.Get(ctx, types.NamespacedName{Name: clusterName + "-global-topo", Namespace: namespace}, ts); !apierrors.IsNotFound(
559+
if err := c.Get(
560+
ctx,
561+
types.NamespacedName{Name: clusterName + "-global-topo", Namespace: namespace},
562+
ts,
563+
); !apierrors.IsNotFound(
535564
err,
536565
) {
537566
t.Fatal("Global TopoServer should NOT be created for External mode")
@@ -543,7 +572,11 @@ func TestReconcile_Global(t *testing.T) {
543572
clusterName,
544573
"zone-a",
545574
)
546-
if err := c.Get(ctx, types.NamespacedName{Name: cellName, Namespace: namespace}, cell); err != nil {
575+
if err := c.Get(
576+
ctx,
577+
types.NamespacedName{Name: cellName, Namespace: namespace},
578+
cell,
579+
); err != nil {
547580
t.Fatalf("Expected Cell %s to exist: %v", cellName, err)
548581
}
549582
if got, want := cell.Spec.GlobalTopoServer.Address, "http://external-etcd:2379"; got != want {
@@ -638,22 +671,37 @@ func TestReconcile_Global(t *testing.T) {
638671
},
639672
validate: func(t testing.TB, c client.Client) {
640673
ts := &multigresv1alpha1.TopoServer{}
641-
if err := c.Get(t.Context(), types.NamespacedName{Name: clusterName + "-global-topo", Namespace: namespace}, ts); err != nil {
674+
if err := c.Get(
675+
t.Context(),
676+
types.NamespacedName{Name: clusterName + "-global-topo", Namespace: namespace},
677+
ts,
678+
); err != nil {
642679
t.Fatal(err)
643680
}
644681
if ts.Spec.Etcd.Image != "new-etcd" {
645682
t.Errorf("TopoServer not updated")
646683
}
647684
deploy := &appsv1.Deployment{}
648-
if err := c.Get(t.Context(), types.NamespacedName{Name: clusterName + "-multiadmin", Namespace: namespace}, deploy); err != nil {
685+
if err := c.Get(
686+
t.Context(),
687+
types.NamespacedName{Name: clusterName + "-multiadmin", Namespace: namespace},
688+
deploy,
689+
); err != nil {
649690
t.Fatal(err)
650691
}
651692
if *deploy.Spec.Replicas != 3 {
652693
t.Errorf("MultiAdmin not updated")
653694
}
654695

655696
webDeploy := &appsv1.Deployment{}
656-
if err := c.Get(t.Context(), types.NamespacedName{Name: clusterName + "-multiadmin-web", Namespace: namespace}, webDeploy); err != nil {
697+
if err := c.Get(
698+
t.Context(),
699+
types.NamespacedName{
700+
Name: clusterName + "-multiadmin-web",
701+
Namespace: namespace,
702+
},
703+
webDeploy,
704+
); err != nil {
657705
t.Fatal(err)
658706
}
659707
if *webDeploy.Spec.Replicas != 2 {

pkg/cluster-handler/controller/multigrescluster/status.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ func (r *MultigresClusterReconciler) updateStatus(
2323
)
2424

2525
cells := &multigresv1alpha1.CellList{}
26-
if err := r.List(ctx, cells, client.InNamespace(cluster.Namespace), client.MatchingLabels{"multigres.com/cluster": cluster.Name}); err != nil {
26+
if err := r.List(
27+
ctx,
28+
cells,
29+
client.InNamespace(cluster.Namespace),
30+
client.MatchingLabels{"multigres.com/cluster": cluster.Name},
31+
); err != nil {
2732
return fmt.Errorf("failed to list cells for status: %w", err)
2833
}
2934

@@ -43,7 +48,12 @@ func (r *MultigresClusterReconciler) updateStatus(
4348
}
4449

4550
tgs := &multigresv1alpha1.TableGroupList{}
46-
if err := r.List(ctx, tgs, client.InNamespace(cluster.Namespace), client.MatchingLabels{"multigres.com/cluster": cluster.Name}); err != nil {
51+
if err := r.List(
52+
ctx,
53+
tgs,
54+
client.InNamespace(cluster.Namespace),
55+
client.MatchingLabels{"multigres.com/cluster": cluster.Name},
56+
); err != nil {
4757
return fmt.Errorf("failed to list tablegroups for status: %w", err)
4858
}
4959

0 commit comments

Comments
 (0)