From 006e5b6a3d9594792f456ac1bda3ab2b84d483ef Mon Sep 17 00:00:00 2001 From: Preston Vasquez Date: Fri, 20 Sep 2024 11:01:54 -0600 Subject: [PATCH 1/4] Bump golangci-lint for 1.23 compatibility --- Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index 7f955eb6ec..a08d20f4ca 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -194,4 +194,4 @@ tasks: install-golangci-lint: internal: true cmds: - - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 \ No newline at end of file + - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 From 227da76b60e1045b6b3260b02fa7c42dbed9a6b9 Mon Sep 17 00:00:00 2001 From: Preston Vasquez Date: Fri, 20 Sep 2024 11:20:07 -0600 Subject: [PATCH 2/4] Fix linting errors --- .pre-commit-config.yaml | 4 ++-- internal/integration/unified/event_verification.go | 2 ++ mongo/client.go | 4 +--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eb873a9e54..0449e06e50 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -51,7 +51,7 @@ repos: exclude: ^(vendor) - repo: https://github.com/golangci/golangci-lint - rev: v1.59.1 + rev: v1.60.1 hooks: - id: golangci-lint @@ -61,4 +61,4 @@ repos: name: executable-shell entry: chmod +x language: system - types: [shell] \ No newline at end of file + types: [shell] diff --git a/internal/integration/unified/event_verification.go b/internal/integration/unified/event_verification.go index 56776d63f5..6847b4999d 100644 --- a/internal/integration/unified/event_verification.go +++ b/internal/integration/unified/event_verification.go @@ -302,6 +302,7 @@ func verifyCommandEvents(ctx context.Context, client *clientEntity, expectedEven return nil } +//nolint:govet func verifyCMAPEvents(client *clientEntity, expectedEvents *expectedEvents) error { pooled := client.poolEvents() if len(expectedEvents.CMAPEvents) == 0 && len(pooled) != 0 { @@ -491,6 +492,7 @@ func getNextTopologyDescriptionChangedEvent( return events[0], events[:1], nil } +//nolint:govet func verifySDAMEvents(client *clientEntity, expectedEvents *expectedEvents) error { var ( changed = client.serverDescriptionChanged diff --git a/mongo/client.go b/mongo/client.go index c9859eff23..b25b29b1b8 100644 --- a/mongo/client.go +++ b/mongo/client.go @@ -921,9 +921,7 @@ func newLogger(opts options.Lister[options.LoggerOptions]) (*logger.Logger, erro // If there are no component-level options and the environment does not // contain component variables, then do nothing. - if (args.ComponentLevels == nil || len(args.ComponentLevels) == 0) && - !logger.EnvHasComponentVariables() { - + if len(args.ComponentLevels) == 0 && !logger.EnvHasComponentVariables() { return nil, nil } From 18b4731114d5e4b801e553fce76e247a39b98083 Mon Sep 17 00:00:00 2001 From: Preston Vasquez Date: Fri, 20 Sep 2024 11:45:52 -0600 Subject: [PATCH 3/4] Remove nolint --- .../integration/unified/event_verification.go | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/internal/integration/unified/event_verification.go b/internal/integration/unified/event_verification.go index 6847b4999d..2ed8270eb2 100644 --- a/internal/integration/unified/event_verification.go +++ b/internal/integration/unified/event_verification.go @@ -302,7 +302,6 @@ func verifyCommandEvents(ctx context.Context, client *clientEntity, expectedEven return nil } -//nolint:govet func verifyCMAPEvents(client *clientEntity, expectedEvents *expectedEvents) error { pooled := client.poolEvents() if len(expectedEvents.CMAPEvents) == 0 && len(pooled) != 0 { @@ -315,16 +314,16 @@ func verifyCMAPEvents(client *clientEntity, expectedEvents *expectedEvents) erro switch { case evt.ConnectionCreatedEvent != nil: if _, pooled, err = getNextPoolEvent(pooled, event.ConnectionCreated); err != nil { - return newEventVerificationError(idx, client, err.Error()) + return newEventVerificationError(idx, client, "failed to get next pool event: %v", err.Error()) } case evt.ConnectionReadyEvent != nil: if _, pooled, err = getNextPoolEvent(pooled, event.ConnectionReady); err != nil { - return newEventVerificationError(idx, client, err.Error()) + return newEventVerificationError(idx, client, "failed to get next pool event: %v", err.Error()) } case evt.ConnectionClosedEvent != nil: var actual *event.PoolEvent if actual, pooled, err = getNextPoolEvent(pooled, event.ConnectionClosed); err != nil { - return newEventVerificationError(idx, client, err.Error()) + return newEventVerificationError(idx, client, "failed to get next pool event: %v", err.Error()) } if expectedReason := evt.ConnectionClosedEvent.Reason; expectedReason != nil { @@ -334,12 +333,12 @@ func verifyCMAPEvents(client *clientEntity, expectedEvents *expectedEvents) erro } case evt.ConnectionCheckedOutEvent != nil: if _, pooled, err = getNextPoolEvent(pooled, event.ConnectionCheckedOut); err != nil { - return newEventVerificationError(idx, client, err.Error()) + return newEventVerificationError(idx, client, "failed to get next pool event: %v", err.Error()) } case evt.ConnectionCheckOutFailedEvent != nil: var actual *event.PoolEvent if actual, pooled, err = getNextPoolEvent(pooled, event.ConnectionCheckOutFailed); err != nil { - return newEventVerificationError(idx, client, err.Error()) + return newEventVerificationError(idx, client, "failed to get next pool event: %v", err.Error()) } if expectedReason := evt.ConnectionCheckOutFailedEvent.Reason; expectedReason != nil { @@ -349,12 +348,12 @@ func verifyCMAPEvents(client *clientEntity, expectedEvents *expectedEvents) erro } case evt.ConnectionCheckedInEvent != nil: if _, pooled, err = getNextPoolEvent(pooled, event.ConnectionCheckedIn); err != nil { - return newEventVerificationError(idx, client, err.Error()) + return newEventVerificationError(idx, client, "failed to get next pool event: %v", err.Error()) } case evt.PoolClearedEvent != nil: var actual *event.PoolEvent if actual, pooled, err = getNextPoolEvent(pooled, event.ConnectionPoolCleared); err != nil { - return newEventVerificationError(idx, client, err.Error()) + return newEventVerificationError(idx, client, "failed to get next pool event: %v", err.Error()) } if expectServiceID := evt.PoolClearedEvent.HasServiceID; expectServiceID != nil { if err := verifyServiceID(*expectServiceID, actual.ServiceID); err != nil { @@ -492,7 +491,6 @@ func getNextTopologyDescriptionChangedEvent( return events[0], events[:1], nil } -//nolint:govet func verifySDAMEvents(client *clientEntity, expectedEvents *expectedEvents) error { var ( changed = client.serverDescriptionChanged @@ -515,7 +513,7 @@ func verifySDAMEvents(client *clientEntity, expectedEvents *expectedEvents) erro case evt.ServerDescriptionChangedEvent != nil: var got *event.ServerDescriptionChangedEvent if got, changed, err = getNextServerDescriptionChangedEvent(changed); err != nil { - return newEventVerificationError(idx, client, err.Error()) + return newEventVerificationError(idx, client, "failed to get next server description changed event: %v", err.Error()) } prevDesc := evt.ServerDescriptionChangedEvent.NewDescription @@ -546,7 +544,7 @@ func verifySDAMEvents(client *clientEntity, expectedEvents *expectedEvents) erro case evt.ServerHeartbeatStartedEvent != nil: var got *event.ServerHeartbeatStartedEvent if got, started, err = getNextServerHeartbeatStartedEvent(started); err != nil { - return newEventVerificationError(idx, client, err.Error()) + return newEventVerificationError(idx, client, "failed to get next server heartbeat event: %v", err.Error()) } if want := evt.ServerHeartbeatStartedEvent.Awaited; want != nil && *want != got.Awaited { @@ -555,7 +553,7 @@ func verifySDAMEvents(client *clientEntity, expectedEvents *expectedEvents) erro case evt.ServerHeartbeatSucceededEvent != nil: var got *event.ServerHeartbeatSucceededEvent if got, succeeded, err = getNextServerHeartbeatSucceededEvent(succeeded); err != nil { - return newEventVerificationError(idx, client, err.Error()) + return newEventVerificationError(idx, client, "failed to get next server heartbeat event: %v", err.Error()) } if want := evt.ServerHeartbeatSucceededEvent.Awaited; want != nil && *want != got.Awaited { @@ -564,7 +562,7 @@ func verifySDAMEvents(client *clientEntity, expectedEvents *expectedEvents) erro case evt.ServerHeartbeatFailedEvent != nil: var got *event.ServerHeartbeatFailedEvent if got, failed, err = getNextServerHeartbeatFailedEvent(failed); err != nil { - return newEventVerificationError(idx, client, err.Error()) + return newEventVerificationError(idx, client, "failed to get next server heartbeat event: %v", err.Error()) } if want := evt.ServerHeartbeatFailedEvent.Awaited; want != nil && *want != got.Awaited { @@ -572,7 +570,7 @@ func verifySDAMEvents(client *clientEntity, expectedEvents *expectedEvents) erro } case evt.TopologyDescriptionChangedEvent != nil: if _, tchanged, err = getNextTopologyDescriptionChangedEvent(tchanged); err != nil { - return newEventVerificationError(idx, client, err.Error()) + return newEventVerificationError(idx, client, "failed to get next description changed event: %v", err.Error()) } } } From 5a59b26ff219258a5d1a2b6ad6c97cf917f94f60 Mon Sep 17 00:00:00 2001 From: Preston Vasquez Date: Fri, 20 Sep 2024 11:48:34 -0600 Subject: [PATCH 4/4] Clarify error strings --- internal/integration/unified/event_verification.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/integration/unified/event_verification.go b/internal/integration/unified/event_verification.go index 2ed8270eb2..ebdb0b19c3 100644 --- a/internal/integration/unified/event_verification.go +++ b/internal/integration/unified/event_verification.go @@ -544,7 +544,7 @@ func verifySDAMEvents(client *clientEntity, expectedEvents *expectedEvents) erro case evt.ServerHeartbeatStartedEvent != nil: var got *event.ServerHeartbeatStartedEvent if got, started, err = getNextServerHeartbeatStartedEvent(started); err != nil { - return newEventVerificationError(idx, client, "failed to get next server heartbeat event: %v", err.Error()) + return newEventVerificationError(idx, client, "failed to get next server heartbeat started event: %v", err.Error()) } if want := evt.ServerHeartbeatStartedEvent.Awaited; want != nil && *want != got.Awaited { @@ -553,7 +553,7 @@ func verifySDAMEvents(client *clientEntity, expectedEvents *expectedEvents) erro case evt.ServerHeartbeatSucceededEvent != nil: var got *event.ServerHeartbeatSucceededEvent if got, succeeded, err = getNextServerHeartbeatSucceededEvent(succeeded); err != nil { - return newEventVerificationError(idx, client, "failed to get next server heartbeat event: %v", err.Error()) + return newEventVerificationError(idx, client, "failed to get next server heartbeat succeeded event: %v", err.Error()) } if want := evt.ServerHeartbeatSucceededEvent.Awaited; want != nil && *want != got.Awaited { @@ -562,7 +562,7 @@ func verifySDAMEvents(client *clientEntity, expectedEvents *expectedEvents) erro case evt.ServerHeartbeatFailedEvent != nil: var got *event.ServerHeartbeatFailedEvent if got, failed, err = getNextServerHeartbeatFailedEvent(failed); err != nil { - return newEventVerificationError(idx, client, "failed to get next server heartbeat event: %v", err.Error()) + return newEventVerificationError(idx, client, "failed to get next server heartbeat failed event: %v", err.Error()) } if want := evt.ServerHeartbeatFailedEvent.Awaited; want != nil && *want != got.Awaited {