Skip to content

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

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

mockgen deprecated: use uber-go/mock instead#157
sebrandon1 wants to merge 1 commit intoopenshift:mainfrom
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

@openshift-ci openshift-ci Bot requested review from RadekManak and nrb November 13, 2025 17:17
@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:
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
Copy Markdown
Member Author

/retest

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4c50dda0-ef49-4a07-bbc6-134063b2050f

📥 Commits

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

⛔ 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 (11)
  • go.mod
  • pkg/actuators/machine/actuator_test.go
  • pkg/actuators/machine/controller_test.go
  • pkg/actuators/machine/dedicatedhosts_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
✅ Files skipped from review due to trivial changes (10)
  • pkg/client/client.go
  • pkg/actuators/machine/dedicatedhosts_test.go
  • pkg/actuators/machine/loadbalancers_test.go
  • go.mod
  • pkg/actuators/machine/instances_test.go
  • pkg/actuators/machine/reconciler_test.go
  • pkg/actuators/machine/controller_test.go
  • pkg/actuators/machine/actuator_test.go
  • pkg/actuators/machine/machine_scope_test.go
  • tools.go

Walkthrough

Switched mock dependency and tooling from github.com/golang/mock to go.uber.org/mock: updated go.mod, tools.go, //go:generate directive, test imports, and regenerated mock file(s) with small signature/struct adjustments.

Changes

Cohort / File(s) Summary
Module file
go.mod
Replaced direct require of github.com/golang/mock with go.uber.org/mock.
Tooling import
tools.go
Replaced tool import _ "github.com/golang/mock/mockgen"_ "go.uber.org/mock/mockgen".
Generate directive
pkg/client/client.go
Updated //go:generate to invoke go.uber.org/mock/mockgen.
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; test logic unchanged.
Generated mocks
pkg/client/mock/client_generated.go
Regenerated mock file: gomock import path updated, added isgomock struct{} fields to exported mocks, recorder parameter types changed from interface{} to any, and generation header comment added.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 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

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

Copy link
Copy Markdown

@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

@sebrandon1 sebrandon1 force-pushed the mockgen_deprecation branch from 32eccd5 to b8ab78b Compare March 20, 2026 19:44
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Mar 21, 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/regression-clusterinfra-aws-ipi-mapi b8ab78b link false /test regression-clusterinfra-aws-ipi-mapi

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.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Mar 21, 2026

PR needs rebase.

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.

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants