Skip to content

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

Open
sebrandon1 wants to merge 3 commits intoopenshift:mainfrom
sebrandon1:mockgen_deprecation
Open

mockgen deprecated: use uber-go/mock instead#157
sebrandon1 wants to merge 3 commits intoopenshift:mainfrom
sebrandon1:mockgen_deprecation

Conversation

@sebrandon1
Copy link
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 the project's mocking tooling to a different mocking library and updated tooling directives to use its generator.
  • Tests

    • Regenerated and updated test mocks to align with the new mocking library and its modernized API, including adjusted mock interfaces for compatibility.

@openshift-ci openshift-ci bot requested review from RadekManak and nrb November 13, 2025 17:17
@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:
Once this PR has been reviewed and has the lgtm label, please assign joelspeed 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

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 18, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 21, 2025
@sebrandon1
Copy link
Member Author

/retest

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 4ec4184 and 32eccd5.

📒 Files selected for processing (1)
  • pkg/actuators/machine/dedicatedhosts_test.go

Walkthrough

Replaces gomock dependency and tooling from github.com/golang/mock to go.uber.org/mock: updates go.mod, tools.go, test imports, the go:generate directive, and regenerates mocks (changed recorder parameter types to any and added isgomock fields).

Changes

Cohort / File(s) Summary
Dependency & tooling
go.mod, tools.go
Removed github.com/golang/mock require; added go.uber.org/mock; updated mockgen tooling import.
Test imports
pkg/actuators/machine/actuator_test.go, pkg/actuators/machine/controller_test.go, pkg/actuators/machine/instances_test.go, pkg/actuators/machine/loadbalancers_test.go, pkg/actuators/machine/machine_scope_test.go, pkg/actuators/machine/reconciler_test.go, pkg/actuators/machine/dedicatedhosts_test.go
Replaced gomock import path github.com/golang/mock/gomockgo.uber.org/mock/gomock in test files; test logic unchanged.
Codegen directive
pkg/client/client.go
Updated //go:generate to use go.uber.org/mock/mockgen.
Generated mocks
pkg/client/mock/client_generated.go
Regenerated mocks: gomock import updated, added isgomock struct{} fields to MockClient and MockRegionCache, and changed recorder method parameter types from interface{} to any.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: migrating from the deprecated golang/mock library to the maintained go.uber.org/mock library, with changes across go.mod, imports in test files, and build configuration.
Stable And Deterministic Test Names ✅ Passed The pull request exclusively migrates the mocking library from github.com/golang/mock to go.uber.org/mock without modifying any test names, which remain stable and deterministic with static descriptive strings.
Test Structure And Quality ✅ Passed PR migrates from archived github.com/golang/mock to maintained go.uber.org/mock with import updates and mock regeneration, preserving all test quality practices including defer cleanup, timeout configuration, meaningful assertions, and logical organization.

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

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

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)
pkg/client/mock/client_generated.go (1)

71-443: Normalize recorder argument types in generated mocks from mixed interface{} and any to consistent any.

The mock file shows three recorder methods using interface{} (AllocateHosts, DescribeHosts, ReleaseHosts) while most others use any. Since both are equivalent in Go 1.18+, normalizing to any across all generated recorder methods will reduce noise in future mock regeneration diffs.

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

In `@pkg/client/mock/client_generated.go` around lines 71 - 443, Recorder methods
AllocateHosts, DescribeHosts, and ReleaseHosts use interface{} for their
parameter types while other recorder methods use any; update the signatures in
MockClientMockRecorder so the parameter type is any (replace interface{} with
any) for AllocateHosts, DescribeHosts, and ReleaseHosts to normalize generated
mock recorder argument types (match methods like DescribeImages, DescribeVpcs,
etc.).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/client/mock/client_generated.go`:
- Around line 71-443: Recorder methods AllocateHosts, DescribeHosts, and
ReleaseHosts use interface{} for their parameter types while other recorder
methods use any; update the signatures in MockClientMockRecorder so the
parameter type is any (replace interface{} with any) for AllocateHosts,
DescribeHosts, and ReleaseHosts to normalize generated mock recorder argument
types (match methods like DescribeImages, DescribeVpcs, etc.).

ℹ️ Review info

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between bcf58df and 7b46ac5.

⛔ Files ignored due to path filters (23)
  • go.sum is excluded by !**/*.sum
  • vendor/github.com/golang/mock/CONTRIBUTORS is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/golang/mock/mockgen/reflect.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/golang/mock/mockgen/version.1.11.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/AUTHORS is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/LICENSE is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/gomock/call.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/gomock/callset.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/gomock/controller.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/gomock/doc.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/gomock/matchers.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/gomock/string.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/archive.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/deprecated.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/generic.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/gob.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/mockgen.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/model/model.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/model/model_gotypes.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/package_mode.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/parse.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/version.go is excluded by !**/vendor/**, !vendor/**
  • vendor/modules.txt is excluded by !**/vendor/**, !vendor/**
📒 Files selected for processing (10)
  • go.mod
  • pkg/actuators/machine/actuator_test.go
  • pkg/actuators/machine/controller_test.go
  • pkg/actuators/machine/instances_test.go
  • pkg/actuators/machine/loadbalancers_test.go
  • pkg/actuators/machine/machine_scope_test.go
  • pkg/actuators/machine/reconciler_test.go
  • pkg/client/client.go
  • pkg/client/mock/client_generated.go
  • tools.go

Update the remaining github.com/golang/mock import to go.uber.org/mock
that was missed in the initial migration.
Sort go.uber.org/mock/gomock after github.com imports to satisfy
goimports check.
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 3, 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/okd-scos-e2e-aws-ovn e6d9150 link false /test okd-scos-e2e-aws-ovn
ci/prow/e2e-aws-serial-1of2 32eccd5 link true /test e2e-aws-serial-1of2

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.

2 participants