Skip to content

Commit 74724a6

Browse files
Update dependency golangci/golangci-lint to v1.61.0 (#2523)
* Update dependency golangci/golangci-lint to v1.61.0 | datasource | package | from | to | | ----------- | ---------------------- | ------- | ------- | | github-tags | golangci/golangci-lint | v1.60.3 | v1.61.0 | Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Fix linter errors --------- Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Luca Comellini <luca.com@gmail.com>
1 parent 7465e62 commit 74724a6

File tree

5 files changed

+36
-39
lines changed

5 files changed

+36
-39
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
4141
with:
4242
working-directory: ${{ matrix.directory }}
43-
version: v1.60.3 # renovate: datasource=github-tags depName=golangci/golangci-lint
43+
version: v1.61.0 # renovate: datasource=github-tags depName=golangci/golangci-lint
4444

4545
njs-lint:
4646
name: NJS Lint

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ repos:
3939
- javascript
4040

4141
- repo: https://github.com/golangci/golangci-lint
42-
rev: v1.60.3
42+
rev: v1.61.0
4343
hooks:
4444
- id: golangci-lint-full
4545
name: golangci-lint-root

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ GO_LINKER_FLAGS = $(GO_LINKER_FLAGS_OPTIMIZATIONS) $(GO_LINKER_FlAGS_VARS)
2424

2525
# tools versions
2626
# renovate: datasource=github-tags depName=golangci/golangci-lint
27-
GOLANGCI_LINT_VERSION = v1.60.3
27+
GOLANGCI_LINT_VERSION = v1.61.0
2828
# renovate: datasource=docker depName=kindest/node
2929
KIND_K8S_VERSION = v1.31.0
3030
# renovate: datasource=github-tags depName=norwoodj/helm-docs

internal/framework/events/loop_test.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package events_test
33
import (
44
"context"
55
"errors"
6+
"time"
67

78
"github.com/go-logr/logr"
89
. "github.com/onsi/ginkgo/v2"
@@ -19,8 +20,6 @@ var _ = Describe("EventLoop", func() {
1920
eventCh chan interface{}
2021
fakePreparer *eventsfakes.FakeFirstEventBatchPreparer
2122
eventLoop *events.EventLoop
22-
ctx context.Context
23-
cancel context.CancelFunc
2423
errorCh chan error
2524
)
2625

@@ -31,12 +30,19 @@ var _ = Describe("EventLoop", func() {
3130

3231
eventLoop = events.NewEventLoop(eventCh, zap.New(), fakeHandler, fakePreparer)
3332

34-
ctx, cancel = context.WithCancel(context.Background())
3533
errorCh = make(chan error)
3634
})
3735

3836
Describe("Normal processing", func() {
3937
BeforeEach(func() {
38+
ctx, cancel := context.WithCancel(context.Background())
39+
DeferCleanup(func(dctx SpecContext) {
40+
cancel()
41+
var err error
42+
Eventually(errorCh).WithContext(dctx).Should(Receive(&err))
43+
Expect(err).ToNot(HaveOccurred())
44+
}, NodeTimeout(time.Second*10))
45+
4046
batch := events.EventBatch{
4147
"event0",
4248
}
@@ -54,14 +60,6 @@ var _ = Describe("EventLoop", func() {
5460
Expect(batch).Should(Equal(expectedBatch))
5561
})
5662

57-
AfterEach(func() {
58-
cancel()
59-
60-
var err error
61-
Eventually(errorCh).Should(Receive(&err))
62-
Expect(err).ToNot(HaveOccurred())
63-
})
64-
6563
// Because BeforeEach() creates the first batch and waits for it to be handled, in the tests below
6664
// HandleEventBatchCallCount() is already 1.
6765

@@ -123,7 +121,7 @@ var _ = Describe("EventLoop", func() {
123121
})
124122

125123
Describe("Edge cases", func() {
126-
It("should return error when preparer returns error without blocking", func() {
124+
It("should return error when preparer returns error without blocking", func(ctx SpecContext) {
127125
preparerError := errors.New("test")
128126
fakePreparer.PrepareReturns(events.EventBatch{}, preparerError)
129127

@@ -132,9 +130,10 @@ var _ = Describe("EventLoop", func() {
132130
Expect(err).Should(MatchError(preparerError))
133131
})
134132

135-
It("should return nil when started with canceled context without blocking", func() {
133+
It("should return nil when started with canceled context without blocking", func(ctx context.Context) {
136134
fakePreparer.PrepareReturns(events.EventBatch{}, nil)
137135

136+
ctx, cancel := context.WithCancel(ctx)
138137
cancel()
139138
err := eventLoop.Start(ctx)
140139

internal/mode/static/telemetry/collector_test.go

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ var _ = Describe("Collector", Ordered, func() {
7878
dataCollector telemetry.DataCollector
7979
version string
8080
expData telemetry.Data
81-
ctx context.Context
8281
podNSName types.NamespacedName
8382
ngfPod *v1.Pod
8483
ngfReplicaSet *appsv1.ReplicaSet
@@ -90,7 +89,6 @@ var _ = Describe("Collector", Ordered, func() {
9089
)
9190

9291
BeforeAll(func() {
93-
ctx = context.Background()
9492
version = "1.1"
9593

9694
ngfPod = &v1.Pod{
@@ -230,7 +228,7 @@ var _ = Describe("Collector", Ordered, func() {
230228

231229
Describe("Normal case", func() {
232230
When("collecting telemetry data", func() {
233-
It("collects all fields", func() {
231+
It("collects all fields", func(ctx SpecContext) {
234232
nodes := &v1.NodeList{
235233
Items: []v1.Node{
236234
{
@@ -396,7 +394,7 @@ var _ = Describe("Collector", Ordered, func() {
396394
Describe("cluster information collector", func() {
397395
When("collecting cluster platform", func() {
398396
When("it encounters an error while collecting data", func() {
399-
It("should error if the kubernetes client errored when getting the NamespaceList", func() {
397+
It("should error if the kubernetes client errored when getting the NamespaceList", func(ctx SpecContext) {
400398
expectedError := errors.New("failed to get NamespaceList")
401399
k8sClientReader.ListCalls(mergeListCallsWithBase(
402400
func(_ context.Context, object client.ObjectList, _ ...client.ListOption) error {
@@ -415,7 +413,7 @@ var _ = Describe("Collector", Ordered, func() {
415413

416414
When("collecting clusterID data", func() {
417415
When("it encounters an error while collecting data", func() {
418-
It("should error if the kubernetes client errored when getting the namespace", func() {
416+
It("should error if the kubernetes client errored when getting the namespace", func(ctx SpecContext) {
419417
expectedError := errors.New("there was an error getting clusterID")
420418
k8sClientReader.GetCalls(mergeGetCallsWithBase(
421419
func(_ context.Context, _ types.NamespacedName, object client.Object, _ ...client.GetOption) error {
@@ -434,7 +432,7 @@ var _ = Describe("Collector", Ordered, func() {
434432

435433
When("collecting cluster version data", func() {
436434
When("the kubelet version is missing", func() {
437-
It("should be report 'unknown'", func() {
435+
It("should be report 'unknown'", func(ctx SpecContext) {
438436
nodes := &v1.NodeList{
439437
Items: []v1.Node{
440438
{
@@ -463,7 +461,7 @@ var _ = Describe("Collector", Ordered, func() {
463461

464462
Describe("node count collector", func() {
465463
When("collecting node count data", func() {
466-
It("collects correct data for one node", func() {
464+
It("collects correct data for one node", func(ctx SpecContext) {
467465
k8sClientReader.ListCalls(createListCallsFunc(nodeList))
468466

469467
expData.Data.ClusterNodeCount = 1
@@ -475,7 +473,7 @@ var _ = Describe("Collector", Ordered, func() {
475473
})
476474

477475
When("it encounters an error while collecting data", func() {
478-
It("should error when there are no nodes", func() {
476+
It("should error when there are no nodes", func(ctx SpecContext) {
479477
expectedError := errors.New("failed to collect cluster information: NodeList length is zero")
480478
k8sClientReader.ListCalls(createListCallsFunc(nil))
481479

@@ -484,7 +482,7 @@ var _ = Describe("Collector", Ordered, func() {
484482
Expect(err).To(MatchError(expectedError))
485483
})
486484

487-
It("should error on kubernetes client api errors", func() {
485+
It("should error on kubernetes client api errors", func(ctx SpecContext) {
488486
expectedError := errors.New("failed to get NodeList")
489487
k8sClientReader.ListCalls(
490488
func(_ context.Context, object client.ObjectList, _ ...client.ListOption) error {
@@ -593,7 +591,7 @@ var _ = Describe("Collector", Ordered, func() {
593591
})
594592

595593
When("collecting NGF resource counts", func() {
596-
It("collects correct data for graph with no resources", func() {
594+
It("collects correct data for graph with no resources", func(ctx SpecContext) {
597595
fakeGraphGetter.GetLatestGraphReturns(&graph.Graph{})
598596
fakeConfigurationGetter.GetLatestConfigurationReturns(&dataplane.Configuration{})
599597

@@ -605,7 +603,7 @@ var _ = Describe("Collector", Ordered, func() {
605603
Expect(expData).To(Equal(data))
606604
})
607605

608-
It("collects correct data for graph with one of each resource", func() {
606+
It("collects correct data for graph with one of each resource", func(ctx SpecContext) {
609607
fakeGraphGetter.GetLatestGraphReturns(graph1)
610608
fakeConfigurationGetter.GetLatestConfigurationReturns(config1)
611609

@@ -629,7 +627,7 @@ var _ = Describe("Collector", Ordered, func() {
629627
Expect(expData).To(Equal(data))
630628
})
631629

632-
It("ignores invalid and empty upstreams", func() {
630+
It("ignores invalid and empty upstreams", func(ctx SpecContext) {
633631
fakeGraphGetter.GetLatestGraphReturns(&graph.Graph{})
634632
fakeConfigurationGetter.GetLatestConfigurationReturns(invalidUpstreamsConfig)
635633
expData.NGFResourceCounts = telemetry.NGFResourceCounts{
@@ -659,15 +657,15 @@ var _ = Describe("Collector", Ordered, func() {
659657
fakeGraphGetter.GetLatestGraphReturns(&graph.Graph{})
660658
fakeConfigurationGetter.GetLatestConfigurationReturns(&dataplane.Configuration{})
661659
})
662-
It("should error on nil latest graph", func() {
660+
It("should error on nil latest graph", func(ctx SpecContext) {
663661
expectedError := errors.New("latest graph cannot be nil")
664662
fakeGraphGetter.GetLatestGraphReturns(nil)
665663

666664
_, err := dataCollector.Collect(ctx)
667665
Expect(err).To(MatchError(expectedError))
668666
})
669667

670-
It("should error on nil latest configuration", func() {
668+
It("should error on nil latest configuration", func(ctx SpecContext) {
671669
expectedError := errors.New("latest configuration cannot be nil")
672670
fakeConfigurationGetter.GetLatestConfigurationReturns(nil)
673671

@@ -681,7 +679,7 @@ var _ = Describe("Collector", Ordered, func() {
681679
Describe("NGF replica count collector", func() {
682680
When("collecting NGF replica count", func() {
683681
When("it encounters an error while collecting data", func() {
684-
It("should error if the kubernetes client errored when getting the Pod", func() {
682+
It("should error if the kubernetes client errored when getting the Pod", func(ctx SpecContext) {
685683
expectedErr := errors.New("there was an error getting the Pod")
686684
k8sClientReader.GetCalls(mergeGetCallsWithBase(
687685
func(_ context.Context, _ client.ObjectKey, object client.Object, _ ...client.GetOption) error {
@@ -697,7 +695,7 @@ var _ = Describe("Collector", Ordered, func() {
697695
Expect(err).To(MatchError(expectedErr))
698696
})
699697

700-
It("should error if the Pod's owner reference is nil", func() {
698+
It("should error if the Pod's owner reference is nil", func(ctx SpecContext) {
701699
expectedErr := errors.New("expected one owner reference of the NGF Pod, got 0")
702700
k8sClientReader.GetCalls(mergeGetCallsWithBase(createGetCallsFunc(
703701
&v1.Pod{
@@ -712,7 +710,7 @@ var _ = Describe("Collector", Ordered, func() {
712710
Expect(err).To(MatchError(expectedErr))
713711
})
714712

715-
It("should error if the Pod has multiple owner references", func() {
713+
It("should error if the Pod has multiple owner references", func(ctx SpecContext) {
716714
expectedErr := errors.New("expected one owner reference of the NGF Pod, got 2")
717715
k8sClientReader.GetCalls(mergeGetCallsWithBase(createGetCallsFunc(
718716
&v1.Pod{
@@ -736,7 +734,7 @@ var _ = Describe("Collector", Ordered, func() {
736734
Expect(err).To(MatchError(expectedErr))
737735
})
738736

739-
It("should error if the Pod's owner reference is not a ReplicaSet", func() {
737+
It("should error if the Pod's owner reference is not a ReplicaSet", func(ctx SpecContext) {
740738
expectedErr := errors.New("expected pod owner reference to be ReplicaSet, got Deployment")
741739
k8sClientReader.GetCalls(mergeGetCallsWithBase(createGetCallsFunc(
742740
&v1.Pod{
@@ -757,7 +755,7 @@ var _ = Describe("Collector", Ordered, func() {
757755
Expect(err).To(MatchError(expectedErr))
758756
})
759757

760-
It("should error if the replica set's replicas is nil", func() {
758+
It("should error if the replica set's replicas is nil", func(ctx SpecContext) {
761759
expectedErr := errors.New("replica set replicas was nil")
762760
k8sClientReader.GetCalls(mergeGetCallsWithBase(createGetCallsFunc(
763761
&appsv1.ReplicaSet{
@@ -771,7 +769,7 @@ var _ = Describe("Collector", Ordered, func() {
771769
Expect(err).To(MatchError(expectedErr))
772770
})
773771

774-
It("should error if the kubernetes client errored when getting the ReplicaSet", func() {
772+
It("should error if the kubernetes client errored when getting the ReplicaSet", func(ctx SpecContext) {
775773
expectedErr := errors.New("there was an error getting the ReplicaSet")
776774
k8sClientReader.GetCalls(mergeGetCallsWithBase(
777775
func(_ context.Context, _ client.ObjectKey, object client.Object, _ ...client.GetOption) error {
@@ -792,7 +790,7 @@ var _ = Describe("Collector", Ordered, func() {
792790
Describe("DeploymentID collector", func() {
793791
When("collecting deploymentID", func() {
794792
When("it encounters an error while collecting data", func() {
795-
It("should error if the replicaSet's owner reference is nil", func() {
793+
It("should error if the replicaSet's owner reference is nil", func(ctx SpecContext) {
796794
replicas := int32(1)
797795
k8sClientReader.GetCalls(mergeGetCallsWithBase(createGetCallsFunc(
798796
&appsv1.ReplicaSet{
@@ -807,7 +805,7 @@ var _ = Describe("Collector", Ordered, func() {
807805
Expect(err).To(MatchError(expectedErr))
808806
})
809807

810-
It("should error if the replicaSet's owner reference kind is not deployment", func() {
808+
It("should error if the replicaSet's owner reference kind is not deployment", func(ctx SpecContext) {
811809
replicas := int32(1)
812810
k8sClientReader.GetCalls(mergeGetCallsWithBase(createGetCallsFunc(
813811
&appsv1.ReplicaSet{
@@ -829,7 +827,7 @@ var _ = Describe("Collector", Ordered, func() {
829827
_, err := dataCollector.Collect(ctx)
830828
Expect(err).To(MatchError(expectedErr))
831829
})
832-
It("should error if the replicaSet's owner reference has empty UID", func() {
830+
It("should error if the replicaSet's owner reference has empty UID", func(ctx SpecContext) {
833831
replicas := int32(1)
834832
k8sClientReader.GetCalls(mergeGetCallsWithBase(createGetCallsFunc(
835833
&appsv1.ReplicaSet{

0 commit comments

Comments
 (0)