CNF-23385: mockgen deprecated: use uber-go/mock instead - #157
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
e6d9150 to
876c2ae
Compare
876c2ae to
fec1f65
Compare
|
/retest |
fec1f65 to
7b46ac5
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughSwapped mock tooling from github.com/golang/mock to go.uber.org/mock: updated ChangesMocking dependency and generated mocks
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 11 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (11 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/client/mock/client_generated.go (1)
71-443: Normalize recorder argument types in generated mocks from mixedinterface{}andanyto consistentany.The mock file shows three recorder methods using
interface{}(AllocateHosts, DescribeHosts, ReleaseHosts) while most others useany. Since both are equivalent in Go 1.18+, normalizing toanyacross 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
⛔ Files ignored due to path filters (23)
go.sumis excluded by!**/*.sumvendor/github.com/golang/mock/CONTRIBUTORSis excluded by!**/vendor/**,!vendor/**vendor/github.com/golang/mock/mockgen/reflect.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/golang/mock/mockgen/version.1.11.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/AUTHORSis excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/LICENSEis excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/gomock/call.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/gomock/callset.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/gomock/controller.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/gomock/doc.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/gomock/matchers.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/gomock/string.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/mockgen/archive.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/mockgen/deprecated.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/mockgen/generic.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/mockgen/gob.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/mockgen/mockgen.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/mockgen/model/model.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/mockgen/model/model_gotypes.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/mockgen/package_mode.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/mockgen/parse.gois excluded by!**/vendor/**,!vendor/**vendor/go.uber.org/mock/mockgen/version.gois excluded by!**/vendor/**,!vendor/**vendor/modules.txtis excluded by!**/vendor/**,!vendor/**
📒 Files selected for processing (10)
go.modpkg/actuators/machine/actuator_test.gopkg/actuators/machine/controller_test.gopkg/actuators/machine/instances_test.gopkg/actuators/machine/loadbalancers_test.gopkg/actuators/machine/machine_scope_test.gopkg/actuators/machine/reconciler_test.gopkg/client/client.gopkg/client/mock/client_generated.gotools.go
32eccd5 to
b8ab78b
Compare
b8ab78b to
27e5b25
Compare
|
@sebrandon1: This pull request references CNF-23385 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
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. |
27e5b25 to
1924d5d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@go.mod`:
- Line 66: The go.mod currently pulls github.com/moby/spdystream v0.5.0
(indirect) via Kubernetes modules; update the Kubernetes module versions (e.g.,
k8s.io/apimachinery, k8s.io/client-go, k8s.io/api, k8s.io/component-base) to a
release that vendors spdystream v0.5.1 or later so the indirect dependency is
upgraded; edit go.mod to bump those k8s module versions (and run go get / go mod
tidy) until github.com/moby/spdystream resolves to v0.5.1+, then verify with go
list -m all that spdystream is v0.5.1 or newer.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: cf552b14-f9f8-4a6c-ae94-5b30c46b7b9c
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (1)
go.mod
| github.com/mattn/go-colorable v0.1.14 // indirect | ||
| github.com/mattn/go-isatty v0.0.20 // indirect | ||
| github.com/mitchellh/go-wordwrap v1.0.1 // indirect | ||
| github.com/moby/spdystream v0.5.0 // indirect |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check for spdystream vulnerability details and dependency chain
echo "=== Vulnerability details ==="
gh api graphql -f query='
{
securityVulnerabilities(first: 5, ecosystem: GO, package: "github.com/moby/spdystream") {
nodes {
advisory {
summary
severity
publishedAt
}
vulnerableVersionRange
firstPatchedVersion {
identifier
}
}
}
}'
echo -e "\n=== Dependency chain for moby/spdystream ==="
go mod graph | grep moby/spdystreamRepository: openshift/machine-api-provider-aws
Length of output: 480
🏁 Script executed:
# Read the go.mod file to see the full context around line 66 and identify dependencies
cat -n go.mod | head -80 | tail -30Repository: openshift/machine-api-provider-aws
Length of output: 2104
🏁 Script executed:
# Check go.sum for spdystream entries
rg "moby/spdystream" go.sumRepository: openshift/machine-api-provider-aws
Length of output: 60
🏁 Script executed:
# Search for which dependency brings in spdystream
rg "moby/spdystream" go.modRepository: openshift/machine-api-provider-aws
Length of output: 125
🏁 Script executed:
# Search for which direct dependency might require spdystream
# Check the requires section and common k8s/container deps
head -50 go.mod | grep -E "^require|^\s+k8s\.io|^\s+github\.com/(kubernetes|moby|containerd|docker)"Repository: openshift/machine-api-provider-aws
Length of output: 304
🏁 Script executed:
# Look for any replace directives that might affect spdystream
rg "replace" go.modRepository: openshift/machine-api-provider-aws
Length of output: 60
🏁 Script executed:
# Search source code for any direct imports of spdystream or related packages
rg "github.com/moby/spdystream|spdystream" --type go .Repository: openshift/machine-api-provider-aws
Length of output: 6660
🏁 Script executed:
# Check if there are newer Kubernetes module versions available
# and whether they would have spdystream v0.5.1
go list -m -versions k8s.io/apimachinery 2>/dev/null | head -5Repository: openshift/machine-api-provider-aws
Length of output: 60
🏁 Script executed:
# Check the current version of spdystream that k8s.io/apimachinery v0.34.1 depends on
# by looking at what direct K8s dependency brings it in
# Let's verify the import chain more clearly
rg "k8s.io/apimachinery" go.mod | head -5Repository: openshift/machine-api-provider-aws
Length of output: 107
🏁 Script executed:
# Search for any constraint or override information in go.mod
cat go.mod | grep -A 5 "^require ("Repository: openshift/machine-api-provider-aws
Length of output: 552
🏁 Script executed:
# Check if there's information in the repository about upgrade paths
# or if there's any documentation mentioning spdystream or k8s version constraints
find . -name "*.md" -o -name "*.txt" | xargs grep -l "spdystream\|k8s\.io.*version" 2>/dev/null | head -5Repository: openshift/machine-api-provider-aws
Length of output: 343
🏁 Script executed:
# Check the GitHub releases or tags for k8s.io/apimachinery newer versions
# Since we can't easily get full listing, let's look for any hints in the codebase
# about planned version updates or vendor information
ls -la go.* vendor/ 2>/dev/null | head -20Repository: openshift/machine-api-provider-aws
Length of output: 1136
Update K8s modules to pull in patched spdystream v0.5.1.
github.com/moby/spdystream v0.5.0 has a HIGH severity denial-of-service vulnerability (GHSA-pc3f-x583-g7j2). This indirect dependency is pulled in by k8s.io/apimachinery (and related K8s modules like k8s.io/client-go, k8s.io/api, k8s.io/component-base), all currently at v0.34.1. Upgrading these K8s modules to a version that includes spdystream v0.5.1 or later will resolve this.
🧰 Tools
🪛 OSV Scanner (2.3.6)
[HIGH] 66-66: github.com/moby/spdystream 0.5.0: SpdyStream: DOS on CRI
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@go.mod` at line 66, The go.mod currently pulls github.com/moby/spdystream
v0.5.0 (indirect) via Kubernetes modules; update the Kubernetes module versions
(e.g., k8s.io/apimachinery, k8s.io/client-go, k8s.io/api, k8s.io/component-base)
to a release that vendors spdystream v0.5.1 or later so the indirect dependency
is upgraded; edit go.mod to bump those k8s module versions (and run go get / go
mod tidy) until github.com/moby/spdystream resolves to v0.5.1+, then verify with
go list -m all that spdystream is v0.5.1 or newer.
|
/retest |
1924d5d to
bd17c27
Compare
|
/retest |
|
/retest-required |
|
@sebrandon1 this has been open for wee while now. Is it still relevant? |
|
/retest |
bd17c27 to
edfeeb0
Compare
edfeeb0 to
5633935
Compare
5633935 to
e461840
Compare
|
@sebrandon1: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
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