Skip to content

HIVE-2998: mockgen deprecated: use uber-go/mock instead#2781

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

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

Conversation

@sebrandon1
Copy link
Copy Markdown
Member

@sebrandon1 sebrandon1 commented Nov 13, 2025

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

Summary by CodeRabbit

  • Chores
    • Migrated mocking framework dependency from golang/mock to go.uber.org/mock, improving test infrastructure and compatibility with modern Go development practices.

@openshift-ci openshift-ci bot requested review from 2uasimojo and jstuever November 13, 2025 17:47
@openshift-ci
Copy link
Copy Markdown
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 suhanime 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

@2uasimojo 2uasimojo changed the title mockgen deprecated: use uber-go/mock instead HIVE-2998: mockgen deprecated: use uber-go/mock instead Nov 13, 2025
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 13, 2025
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Nov 13, 2025

@sebrandon1: This pull request references HIVE-2998 which is a valid jira issue.

Details

In response to this:

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

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 28, 2026
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 28, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.31%. Comparing base (4caba33) to head (8f07f69).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2781   +/-   ##
=======================================
  Coverage   50.31%   50.31%           
=======================================
  Files         280      280           
  Lines       34314    34314           
=======================================
  Hits        17264    17264           
  Misses      15689    15689           
  Partials     1361     1361           
Files with missing lines Coverage Δ
pkg/awsclient/mock/client_generated.go 68.76% <ø> (ø)
pkg/azureclient/mock/client_generated.go 69.66% <ø> (ø)
...ler/dnsendpoint/nameserver/mock/query_generated.go 100.00% <ø> (ø)
pkg/controller/dnszone/test_helpers.go 100.00% <ø> (ø)
...ontroller/hibernation/mock/csr_helper_generated.go 100.00% <ø> (ø)
...hibernation/mock/hibernation_actuator_generated.go 76.92% <ø> (ø)
.../controller/machinepool/mock/actuator_generated.go 100.00% <ø> (ø)
...er/privatelink/actuator/mock/actuator_generated.go 100.00% <ø> (ø)
pkg/gcpclient/mock/client_generated.go 85.56% <ø> (ø)
pkg/ibmclient/mock/client_generated.go 36.94% <ø> (ø)
... and 3 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sebrandon1
Copy link
Copy Markdown
Member Author

/retest

@red-hat-konflux
Copy link
Copy Markdown
Contributor

Caution

There are some errors in your PipelineRun template.

PipelineRun Error
hive-mce-210-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\" && !body.pull_request.draft && target_branch == \"master\" && !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request
hive-mce-211-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\" && !body.pull_request.draft && target_branch == \"master\" && !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request
hive-mce-26-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\" && !body.pull_request.draft && target_branch == \"master\" && !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request
hive-mce-27-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\" && !body.pull_request.draft && target_branch == \"master\" && !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request
hive-mce-28-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\" && !body.pull_request.draft && target_branch == \"master\" && !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request
hive-mce-29-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\" && !body.pull_request.draft && target_branch == \"master\" && !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request
hive-on-pull-request CEL expression evaluation error: expression "event == \"pull_request\" && !body.pull_request.draft && target_branch == \"master\" && !files.all.all(x, x.matches('^docs/|\\\\.md$|^(?:.*/)?(?:\\\\.gitignore|OWNERS|PROJECT|LICENSE)$'))\n" failed to evaluate: no such key: pull_request

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 9, 2026
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 18, 2026
@sebrandon1 sebrandon1 force-pushed the mockgen_deprecation branch 2 times, most recently from 0745186 to 9df3aaa Compare March 2, 2026 20:15
https://github.com/golang/mock is marked as archived as of June 27, 2023.
They recommend using go.uber.org/mock.

This PR changes the dependency to one that is maintained.

Changes:
- Updated Makefile to install uber-go/mock mockgen
- Updated go.mod/go.sum to use go.uber.org/mock v0.6.0
- Updated all test files to import go.uber.org/mock/gomock
- Updated all generated mock files
- Fixed gomock.InOrder calls to use []any instead of []*gomock.Call
- Re-vendored dependencies

Tracking issue: redhat-best-practices-for-k8s/telco-bot#45
@sebrandon1 sebrandon1 force-pushed the mockgen_deprecation branch from 9df3aaa to 8f07f69 Compare March 20, 2026 19:44
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bbc3550d-a4c7-42f0-af66-c354417ba692

📥 Commits

Reviewing files that changed from the base of the PR and between 4caba33 and 8f07f69.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (74)
  • Makefile
  • go.mod
  • pkg/awsclient/mock/client_generated.go
  • pkg/azureclient/mock/client_generated.go
  • pkg/controller/awsprivatelink/awsprivatelink_controller_test.go
  • pkg/controller/awsprivatelink/cleanup_test.go
  • pkg/controller/clusterdeployment/clusterdeployment_controller_test.go
  • pkg/controller/clusterdeprovision/clusterdeprovision_controller_test.go
  • pkg/controller/clusterdeprovision/helpers_test.go
  • pkg/controller/clusterrelocate/clusterrelocate_controller_test.go
  • pkg/controller/clusterstate/clusterstate_controller_test.go
  • pkg/controller/clustersync/clustersync_controller_test.go
  • pkg/controller/clusterversion/clusterversion_controller_test.go
  • pkg/controller/dnsendpoint/dnsendpoint_controller_test.go
  • pkg/controller/dnsendpoint/nameserver/aws_test.go
  • pkg/controller/dnsendpoint/nameserver/azure_test.go
  • pkg/controller/dnsendpoint/nameserver/gcp_test.go
  • pkg/controller/dnsendpoint/nameserver/mock/query_generated.go
  • pkg/controller/dnsendpoint/nameserverscraper_test.go
  • pkg/controller/dnszone/awsactuator_test.go
  • pkg/controller/dnszone/azureactuator_test.go
  • pkg/controller/dnszone/dnszone_controller_test.go
  • pkg/controller/dnszone/gcpactuator_test.go
  • pkg/controller/dnszone/test_helpers.go
  • pkg/controller/hibernation/aws_actuator_test.go
  • pkg/controller/hibernation/azure_actuator_test.go
  • pkg/controller/hibernation/gcp_actuator_test.go
  • pkg/controller/hibernation/hibernation_controller_test.go
  • pkg/controller/hibernation/ibmcloud_actuator_test.go
  • pkg/controller/hibernation/mock/csr_helper_generated.go
  • pkg/controller/hibernation/mock/hibernation_actuator_generated.go
  • pkg/controller/machinepool/awsactuator_test.go
  • pkg/controller/machinepool/azureactuator_test.go
  • pkg/controller/machinepool/gcpactuator_test.go
  • pkg/controller/machinepool/ibmcloudactuator_test.go
  • pkg/controller/machinepool/machinepool_controller_test.go
  • pkg/controller/machinepool/mock/actuator_generated.go
  • pkg/controller/privatelink/actuator/awsactuator/awshubactuator_test.go
  • pkg/controller/privatelink/actuator/gcpactuator/gcplinkactuator_test.go
  • pkg/controller/privatelink/actuator/mock/actuator_generated.go
  • pkg/controller/privatelink/privatelink_test.go
  • pkg/controller/unreachable/unreachable_controller_test.go
  • pkg/controller/velerobackup/velerobackup_controller_test.go
  • pkg/dependencymagnet/doc.go
  • pkg/gcpclient/mock/client_generated.go
  • pkg/ibmclient/mock/client_generated.go
  • pkg/installmanager/helper_test.go
  • pkg/installmanager/ibm_metadata_test.go
  • pkg/installmanager/s3loguploaderactuator_test.go
  • pkg/remoteclient/mock/remoteclient_generated.go
  • pkg/resource/mock/helper_generated.go
  • pkg/test/manager/mock/manager_generated.go
  • vendor/github.com/golang/mock/CONTRIBUTORS
  • vendor/github.com/golang/mock/mockgen/generic_notgo118.go
  • vendor/github.com/golang/mock/mockgen/reflect.go
  • vendor/go.uber.org/mock/AUTHORS
  • vendor/go.uber.org/mock/LICENSE
  • vendor/go.uber.org/mock/gomock/call.go
  • vendor/go.uber.org/mock/gomock/callset.go
  • vendor/go.uber.org/mock/gomock/controller.go
  • vendor/go.uber.org/mock/gomock/doc.go
  • vendor/go.uber.org/mock/gomock/matchers.go
  • vendor/go.uber.org/mock/gomock/string.go
  • vendor/go.uber.org/mock/mockgen/archive.go
  • vendor/go.uber.org/mock/mockgen/deprecated.go
  • vendor/go.uber.org/mock/mockgen/generic.go
  • vendor/go.uber.org/mock/mockgen/gob.go
  • vendor/go.uber.org/mock/mockgen/mockgen.go
  • vendor/go.uber.org/mock/mockgen/model/model.go
  • vendor/go.uber.org/mock/mockgen/model/model_gotypes.go
  • vendor/go.uber.org/mock/mockgen/package_mode.go
  • vendor/go.uber.org/mock/mockgen/parse.go
  • vendor/go.uber.org/mock/mockgen/version.go
  • vendor/modules.txt
💤 Files with no reviewable changes (3)
  • vendor/github.com/golang/mock/mockgen/generic_notgo118.go
  • vendor/github.com/golang/mock/CONTRIBUTORS
  • vendor/github.com/golang/mock/mockgen/reflect.go

📝 Walkthrough

Walkthrough

This pull request migrates the codebase from the deprecated github.com/golang/mock to go.uber.org/mock, updating the go.mod dependency, Makefile tool installation, and approximately 50+ test files and generated mocks to import gomock from the new module path. Vendor directory entries are correspondingly updated.

Changes

Cohort / File(s) Summary
Build Configuration
Makefile, go.mod
Updated mockgen tool source from github.com/golang/mock/mockgen to go.uber.org/mock/mockgen and replaced module dependency from github.com/golang/mock v1.7.0-rc.1 to go.uber.org/mock v0.6.0.
Generated Mock Files
pkg/awsclient/mock/client_generated.go, pkg/azureclient/mock/client_generated.go, pkg/gcpclient/mock/client_generated.go, pkg/ibmclient/mock/client_generated.go, pkg/remoteclient/mock/remoteclient_generated.go, pkg/controller/.../mock/*_generated.go, pkg/resource/mock/helper_generated.go, pkg/test/manager/mock/manager_generated.go
Updated GoMock import paths from github.com/golang/mock/gomock to go.uber.org/mock/gomock in generated mock types and methods.
AWS Controller Test Files
pkg/controller/awsprivatelink/awsprivatelink_controller_test.go, pkg/controller/awsprivatelink/cleanup_test.go
Updated gomock import path in test files.
Cluster-Related Controller Tests
pkg/controller/clusterdeployment/clusterdeployment_controller_test.go, pkg/controller/clusterdeprovision/clusterdeprovision_controller_test.go, pkg/controller/clusterdeprovision/helpers_test.go, pkg/controller/clusterrelocate/clusterrelocate_controller_test.go, pkg/controller/clusterstate/clusterstate_controller_test.go, pkg/controller/clustersync/clustersync_controller_test.go, pkg/controller/clusterversion/clusterversion_controller_test.go
Updated gomock import paths. clustersync_controller_test.go also changed resourceHelperCalls type from []*gomock.Call to []any.
DNS-Related Controller Tests
pkg/controller/dnsendpoint/dnsendpoint_controller_test.go, pkg/controller/dnsendpoint/nameserver/aws_test.go, pkg/controller/dnsendpoint/nameserver/azure_test.go, pkg/controller/dnsendpoint/nameserver/gcp_test.go, pkg/controller/dnsendpoint/nameserver/mock/query_generated.go, pkg/controller/dnsendpoint/nameserverscraper_test.go, pkg/controller/dnszone/awsactuator_test.go, pkg/controller/dnszone/azureactuator_test.go, pkg/controller/dnszone/dnszone_controller_test.go, pkg/controller/dnszone/gcpactuator_test.go, pkg/controller/dnszone/test_helpers.go
Updated gomock import paths across DNS endpoint and zone controller test files.
Hibernation Controller Tests
pkg/controller/hibernation/aws_actuator_test.go, pkg/controller/hibernation/azure_actuator_test.go, pkg/controller/hibernation/gcp_actuator_test.go, pkg/controller/hibernation/hibernation_controller_test.go, pkg/controller/hibernation/ibmcloud_actuator_test.go, pkg/controller/hibernation/mock/csr_helper_generated.go, pkg/controller/hibernation/mock/hibernation_actuator_generated.go
Updated gomock import paths in hibernation-related test files and generated mocks.
Machine Pool Controller Tests
pkg/controller/machinepool/awsactuator_test.go, pkg/controller/machinepool/azureactuator_test.go, pkg/controller/machinepool/gcpactuator_test.go, pkg/controller/machinepool/ibmcloudactuator_test.go, pkg/controller/machinepool/machinepool_controller_test.go, pkg/controller/machinepool/mock/actuator_generated.go
Updated gomock import paths in machine pool test files and generated mocks.
Private Link & Other Controllers
pkg/controller/privatelink/actuator/awsactuator/awshubactuator_test.go, pkg/controller/privatelink/actuator/gcpactuator/gcplinkactuator_test.go, pkg/controller/privatelink/actuator/mock/actuator_generated.go, pkg/controller/privatelink/privatelink_test.go, pkg/controller/unreachable/unreachable_controller_test.go, pkg/controller/velerobackup/velerobackup_controller_test.go
Updated gomock import paths in remaining controller test files.
Installer & Client Tests
pkg/dependencymagnet/doc.go, pkg/installmanager/helper_test.go, pkg/installmanager/ibm_metadata_test.go, pkg/installmanager/s3loguploaderactuator_test.go
Updated gomock import paths in installer and dependency management related test files.
Removed Vendor Code
vendor/github.com/golang/mock/...
Removed entire golang/mock vendor directory including CONTRIBUTORS file, mockgen utilities, and reflection mode implementation.
Added Uber Mock Vendor Code
vendor/go.uber.org/mock/gomock/..., vendor/go.uber.org/mock/mockgen/...
Added new uber fork of gomock with significant API enhancements: interface{} replaced with any throughout; new ControllerOption interface with WithOverridableExpectations() function; InOrder() signature expanded to accept ...any; new matchers (Cond, AnyOf, Regex); enhanced call set with override capability and thread-safety via sync.Mutex; new archive and gob generation modes; typed call support; generic type-parameter handling via package-mode parser.
Vendor Module Metadata
vendor/modules.txt
Updated vendored module list to remove github.com/golang/mock v1.7.0-rc.1 and add go.uber.org/mock v0.6.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes


Poem

🐰 Hops of joy! A new mock arrives—
Uber's gomock now thrives,
No more interface{}, just any so neat,
With typed calls and constraints—what a treat!
From golang to uber, our journey's complete!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly reflects the main objective: migrating from deprecated golang/mock to the maintained go.uber.org/mock implementation, which is the primary change across the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Mar 20, 2026

@sebrandon1: This pull request references HIVE-2998 which is a valid jira issue.

Details

In response to this:

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

Summary by CodeRabbit

  • Chores
  • Migrated mocking framework dependency from golang/mock to go.uber.org/mock, improving test infrastructure and compatibility with modern Go development practices.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 20, 2026

@sebrandon1: The following tests 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/e2e-vsphere e3aff7f link true /test e2e-vsphere
ci/prow/e2e-openstack e3aff7f link true /test e2e-openstack
ci/prow/e2e-azure 8f07f69 link true /test e2e-azure
ci/prow/verify 8f07f69 link true /test verify
ci/prow/security 8f07f69 link true /test security

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

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants