Skip to content

Commit

Permalink
Update dependency golangci/golangci-lint to v1.61.0 (#2523)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
renovate[bot] and lucacome authored Sep 11, 2024
1 parent 7465e62 commit 74724a6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
working-directory: ${{ matrix.directory }}
version: v1.60.3 # renovate: datasource=github-tags depName=golangci/golangci-lint
version: v1.61.0 # renovate: datasource=github-tags depName=golangci/golangci-lint

njs-lint:
name: NJS Lint
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repos:
- javascript

- repo: https://github.com/golangci/golangci-lint
rev: v1.60.3
rev: v1.61.0
hooks:
- id: golangci-lint-full
name: golangci-lint-root
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ GO_LINKER_FLAGS = $(GO_LINKER_FLAGS_OPTIMIZATIONS) $(GO_LINKER_FlAGS_VARS)

# tools versions
# renovate: datasource=github-tags depName=golangci/golangci-lint
GOLANGCI_LINT_VERSION = v1.60.3
GOLANGCI_LINT_VERSION = v1.61.0
# renovate: datasource=docker depName=kindest/node
KIND_K8S_VERSION = v1.31.0
# renovate: datasource=github-tags depName=norwoodj/helm-docs
Expand Down
25 changes: 12 additions & 13 deletions internal/framework/events/loop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package events_test
import (
"context"
"errors"
"time"

"github.com/go-logr/logr"
. "github.com/onsi/ginkgo/v2"
Expand All @@ -19,8 +20,6 @@ var _ = Describe("EventLoop", func() {
eventCh chan interface{}
fakePreparer *eventsfakes.FakeFirstEventBatchPreparer
eventLoop *events.EventLoop
ctx context.Context
cancel context.CancelFunc
errorCh chan error
)

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

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

ctx, cancel = context.WithCancel(context.Background())
errorCh = make(chan error)
})

Describe("Normal processing", func() {
BeforeEach(func() {
ctx, cancel := context.WithCancel(context.Background())
DeferCleanup(func(dctx SpecContext) {
cancel()
var err error
Eventually(errorCh).WithContext(dctx).Should(Receive(&err))
Expect(err).ToNot(HaveOccurred())
}, NodeTimeout(time.Second*10))

batch := events.EventBatch{
"event0",
}
Expand All @@ -54,14 +60,6 @@ var _ = Describe("EventLoop", func() {
Expect(batch).Should(Equal(expectedBatch))
})

AfterEach(func() {
cancel()

var err error
Eventually(errorCh).Should(Receive(&err))
Expect(err).ToNot(HaveOccurred())
})

// Because BeforeEach() creates the first batch and waits for it to be handled, in the tests below
// HandleEventBatchCallCount() is already 1.

Expand Down Expand Up @@ -123,7 +121,7 @@ var _ = Describe("EventLoop", func() {
})

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

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

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

ctx, cancel := context.WithCancel(ctx)
cancel()
err := eventLoop.Start(ctx)

Expand Down
44 changes: 21 additions & 23 deletions internal/mode/static/telemetry/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ var _ = Describe("Collector", Ordered, func() {
dataCollector telemetry.DataCollector
version string
expData telemetry.Data
ctx context.Context
podNSName types.NamespacedName
ngfPod *v1.Pod
ngfReplicaSet *appsv1.ReplicaSet
Expand All @@ -90,7 +89,6 @@ var _ = Describe("Collector", Ordered, func() {
)

BeforeAll(func() {
ctx = context.Background()
version = "1.1"

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

Describe("Normal case", func() {
When("collecting telemetry data", func() {
It("collects all fields", func() {
It("collects all fields", func(ctx SpecContext) {
nodes := &v1.NodeList{
Items: []v1.Node{
{
Expand Down Expand Up @@ -396,7 +394,7 @@ var _ = Describe("Collector", Ordered, func() {
Describe("cluster information collector", func() {
When("collecting cluster platform", func() {
When("it encounters an error while collecting data", func() {
It("should error if the kubernetes client errored when getting the NamespaceList", func() {
It("should error if the kubernetes client errored when getting the NamespaceList", func(ctx SpecContext) {
expectedError := errors.New("failed to get NamespaceList")
k8sClientReader.ListCalls(mergeListCallsWithBase(
func(_ context.Context, object client.ObjectList, _ ...client.ListOption) error {
Expand All @@ -415,7 +413,7 @@ var _ = Describe("Collector", Ordered, func() {

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

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

Describe("node count collector", func() {
When("collecting node count data", func() {
It("collects correct data for one node", func() {
It("collects correct data for one node", func(ctx SpecContext) {
k8sClientReader.ListCalls(createListCallsFunc(nodeList))

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

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

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

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

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

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

It("collects correct data for graph with one of each resource", func() {
It("collects correct data for graph with one of each resource", func(ctx SpecContext) {
fakeGraphGetter.GetLatestGraphReturns(graph1)
fakeConfigurationGetter.GetLatestConfigurationReturns(config1)

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

It("ignores invalid and empty upstreams", func() {
It("ignores invalid and empty upstreams", func(ctx SpecContext) {
fakeGraphGetter.GetLatestGraphReturns(&graph.Graph{})
fakeConfigurationGetter.GetLatestConfigurationReturns(invalidUpstreamsConfig)
expData.NGFResourceCounts = telemetry.NGFResourceCounts{
Expand Down Expand Up @@ -659,15 +657,15 @@ var _ = Describe("Collector", Ordered, func() {
fakeGraphGetter.GetLatestGraphReturns(&graph.Graph{})
fakeConfigurationGetter.GetLatestConfigurationReturns(&dataplane.Configuration{})
})
It("should error on nil latest graph", func() {
It("should error on nil latest graph", func(ctx SpecContext) {
expectedError := errors.New("latest graph cannot be nil")
fakeGraphGetter.GetLatestGraphReturns(nil)

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

It("should error on nil latest configuration", func() {
It("should error on nil latest configuration", func(ctx SpecContext) {
expectedError := errors.New("latest configuration cannot be nil")
fakeConfigurationGetter.GetLatestConfigurationReturns(nil)

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

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

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

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

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

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

It("should error if the replicaSet's owner reference kind is not deployment", func() {
It("should error if the replicaSet's owner reference kind is not deployment", func(ctx SpecContext) {
replicas := int32(1)
k8sClientReader.GetCalls(mergeGetCallsWithBase(createGetCallsFunc(
&appsv1.ReplicaSet{
Expand All @@ -829,7 +827,7 @@ var _ = Describe("Collector", Ordered, func() {
_, err := dataCollector.Collect(ctx)
Expect(err).To(MatchError(expectedErr))
})
It("should error if the replicaSet's owner reference has empty UID", func() {
It("should error if the replicaSet's owner reference has empty UID", func(ctx SpecContext) {
replicas := int32(1)
k8sClientReader.GetCalls(mergeGetCallsWithBase(createGetCallsFunc(
&appsv1.ReplicaSet{
Expand Down

0 comments on commit 74724a6

Please sign in to comment.