Skip to content

Comments

mockgen deprecated: use uber-go/mock instead#561

Open
sebrandon1 wants to merge 1 commit intoopenshift:masterfrom
sebrandon1:mockgen_deprecation
Open

mockgen deprecated: use uber-go/mock instead#561
sebrandon1 wants to merge 1 commit intoopenshift:masterfrom
sebrandon1:mockgen_deprecation

Conversation

@sebrandon1
Copy link
Member

https://github.com/golang/mock is marked as archived as of June 27, 2023. They recommend using go.uber.org/mock.

This PR attempts to change the dependency to one that is maintained.

Tracking issue: redhat-best-practices-for-k8s/telco-bot#45

@openshift-ci openshift-ci bot requested review from Tafhim and devppratik November 13, 2025 18:03
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 13, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sebrandon1
Once this PR has been reviewed and has the lgtm label, please assign clcollins for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 68.57143% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.59%. Comparing base (7be1977) to head (d25a4af).

Files with missing lines Patch % Lines
pkg/ocm/mocks/client.go 0.00% 12 Missing ⚠️
...kg/alertmanager/mocks/alertManagerSilenceClient.go 60.00% 8 Missing ⚠️
pkg/metrics/mocks/metrics.go 50.00% 8 Missing ⚠️
pkg/maintenance/mocks/maintenance.go 66.66% 4 Missing ⚠️
pkg/ocm/mocks/builder.go 0.00% 4 Missing ⚠️
pkg/ocmagent/mocks/builder.go 0.00% 4 Missing ⚠️
...upgradeconfigmanager/mocks/upgradeconfigmanager.go 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #561   +/-   ##
=======================================
  Coverage   53.59%   53.59%           
=======================================
  Files         123      123           
  Lines        6165     6165           
=======================================
  Hits         3304     3304           
  Misses       2668     2668           
  Partials      193      193           
Files with missing lines Coverage Δ
mocks/builder.go 0.00% <ø> (ø)
mocks/client.go 0.00% <ø> (ø)
pkg/alertmanager/alertManagerSilenceClient.go 0.00% <ø> (ø)
pkg/availabilitychecks/availabilitychecks.go 0.00% <ø> (ø)
...availabilitychecks/mocks/mockAvailabilityChecks.go 100.00% <ø> (ø)
pkg/clusterversion/mocks/mockClusterVersion.go 100.00% <100.00%> (ø)
.../clusterversion/mocks/mockClusterVersionBuilder.go 100.00% <ø> (ø)
pkg/configmanager/config.go 0.00% <ø> (ø)
pkg/configmanager/mocks/configmanager.go 100.00% <ø> (ø)
pkg/configmanager/mocks/configmanagerbuilder.go 100.00% <ø> (ø)
... and 34 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tkong-redhat
Copy link
Contributor

/retest

@sebrandon1
Copy link
Member Author

/retest

@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

Walkthrough

This pull request migrates the codebase from golang/mock to uber-go/mock, refactors mock structs by adding isgomock fields for gomock compatibility, renames generic mock parameters (arg0, arg1, etc.) to descriptive names, updates kubebuilder marker formatting, adds go:generate directive comments, and applies miscellaneous formatting adjustments across the codebase.

Changes

Cohort / File(s) Summary
Mock Framework Import Migration
mocks/builder.go, mocks/client.go, go.mod, docs/testing.md
Replaced golang/mock imports with uber-go/mock; updated GoMock reference URLs and dependency versions in go.mod (golang/mock v1.6.0 removed, go.uber.org/mock v0.4.0 → v0.6.0).
kubebuilder Marker Syntax Updates
api/v1alpha1/groupversion_info.go
Updated kubebuilder marker comments from no-space format (//+kubebuilder) to space-prefixed format (// +kubebuilder) on two marker lines.
Mock isgomock Field Additions
pkg/alertmanager/mocks/alertManagerSilenceClient.go, pkg/availabilitychecks/mocks/mockAvailabilityChecks.go, pkg/clusterversion/mocks/mockClusterVersion.go, pkg/clusterversion/mocks/mockClusterVersionBuilder.go, pkg/configmanager/mocks/configmanager.go, pkg/configmanager/mocks/configmanagerbuilder.go, pkg/drain/drainStrategyMock.go, pkg/drain/mocks/nodeDrainStrategy.go, pkg/drain/timedDrainStrategyMock.go, pkg/dvo/mocks/client.go, pkg/eventmanager/mocks/eventmanager.go, pkg/eventmanager/mocks/eventmanager_builder.go, pkg/maintenance/mocks/maintenance.go, pkg/maintenance/mocks/maintenanceBuilder.go, pkg/metrics/mocks/metrics.go, pkg/notifier/mocks/notifier.go, pkg/notifier/mocks/notifier_builder.go, pkg/ocm/mocks/client.go, pkg/scaler/mocks/scaler.go, pkg/scheduler/mocks/mockScheduler.go, pkg/specprovider/mocks/specprovider.go, pkg/specprovider/mocks/specprovider_builder.go, pkg/upgradeconfigmanager/mocks/upgradeconfigmanager.go, pkg/upgradeconfigmanager/mocks/upgradeconfigmanager_builder.go, pkg/upgraders/mocks/cluster_upgrader.go, pkg/upgraders/mocks/cluster_upgrader_builder.go, pkg/validation/mocks/mockValidation.go, pkg/validation/mocks/mockValidationBuilder.go
Added isgomock struct{} field to all mock structs for gomock internal compatibility.
Mock Method Parameter Refactoring
pkg/alertmanager/mocks/alertManagerSilenceClient.go, pkg/clusterversion/mocks/mockClusterVersion.go, pkg/drain/mocks/nodeDrainStrategyBuilder.go, pkg/dvo/mocks/builder.go, pkg/eventmanager/mocks/eventmanager.go, pkg/machinery/mocks/machinery.go, pkg/maintenance/mocks/maintenance.go, pkg/metrics/mocks/metrics.go, pkg/metrics/mocks/metrics_builder.go, pkg/notifier/mocks/notifier.go, pkg/ocm/mocks/builder.go, pkg/ocm/mocks/client.go, pkg/ocmagent/mocks/builder.go, pkg/upgradeconfigmanager/mocks/upgradeconfigmanager.go, pkg/upgraders/mocks/cluster_upgrader.go, pkg/validation/mocks/mockValidation.go
Renamed generic mock method parameters from argX format to descriptive names (e.g., arg0 → c, arg1 → logger, arg0 → id); updated both method signatures and recorder methods accordingly.
go:generate Directive Comment Formatting
pkg/alertmanager/alertManagerSilenceClient.go, pkg/availabilitychecks/availabilitychecks.go, pkg/configmanager/config.go, pkg/dvo/builder.go, pkg/maintenance/maintenance.go, pkg/specprovider/specprovider.go
Added blank comment lines preceding go:generate directives for improved formatting and readability.
Miscellaneous Formatting and Build Constraints
pkg/specprovider/config.go, pkg/upgradesteps/action.go, pkg/upgradesteps/runner_test.go, pkg/ocmagent/client_test.go, tools.go
Updated field whitespace alignment, import ordering, test setup indentation, and added //go:build tools constraint for backward compatibility.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.5.0)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
mocks/client.go (1)

13-17: Regenerate mocks in the mocks/ directory with the current mockgen version.

The mocks/client.go (MockDvoClient) and mocks/builder.go (MockDvoClientBuilder) lack the isgomock struct{} field present in all other generated mocks in the repository. This indicates the mocks/ directory was generated with an older mockgen version. Regenerate both files to align with the current format used throughout the codebase (e.g., pkg/dvo/mocks/, pkg/notifier/mocks/).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mocks/client.go` around lines 13 - 17, Regenerate the mock files for
MockDvoClient and MockDvoClientBuilder using the current mockgen version so they
include the missing isgomock struct{} field (the other generated mocks in the
repo have this field); run mockgen against the DvoClient interface and replace
the contents of the existing mocks/client.go and mocks/builder.go with the newly
generated output so the MockDvoClient and MockDvoClientBuilder types match the
modern mockgen format.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@mocks/client.go`:
- Around line 13-17: Regenerate the mock files for MockDvoClient and
MockDvoClientBuilder using the current mockgen version so they include the
missing isgomock struct{} field (the other generated mocks in the repo have this
field); run mockgen against the DvoClient interface and replace the contents of
the existing mocks/client.go and mocks/builder.go with the newly generated
output so the MockDvoClient and MockDvoClientBuilder types match the modern
mockgen format.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 18, 2026

@sebrandon1: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/validate d25a4af link true /test validate

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants