ROSAENG-61040 | refactor: remove github.com/PuerkitoBio/goquery#3422
ROSAENG-61040 | refactor: remove github.com/PuerkitoBio/goquery#3422markirish wants to merge 1 commit into
Conversation
Replace goquery HTML DOM parsing with a ~50-line golang.org/x/net/html tokenizer for extracting version links from the OpenShift mirror page. Promote golang.org/x/net from indirect to direct dependency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughMirror version discovery now uses Go’s streaming HTML tokenizer instead of DOM parsing. It extracts version links from file rows, excludes the Suggested reviewers: 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: markirish 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pkg/version/retriever_test.go (1)
20-30: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the new row and
latestfilters.This fixture cannot detect accepting links outside
tr.fileor retaininglatest. Add a non-file high version and atr.filelatest/link, then assert the parsed slice excludes both.As per coding guidelines, “Add focused automated tests when behavior changes could regress; tests should prove correctness.”
🤖 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 `@pkg/version/retriever_test.go` around lines 20 - 30, Add focused fixture coverage around the version-parsing test using expectedVersions and htmlContent: include a high-version link outside tr.file and a latest/ link inside tr.file, then assert the parsed versions exclude both while preserving the existing valid versions.Sources: Coding guidelines, Path instructions
pkg/version/retriever.go (1)
105-107: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid shadowing
erron the cache write.Line 105 shadows the parser error variable. Use a distinct
cacheErrto keep error paths unambiguous.Proposed fix
-if err := r.cache.Set(cache.VersionCacheKey, possibleVersions); err != nil { - r.logger.Debugf("Failed to set possible versions in cache : %v", err) +if cacheErr := r.cache.Set(cache.VersionCacheKey, possibleVersions); cacheErr != nil { + r.logger.Debugf("Failed to set possible versions in cache : %v", cacheErr) }As per coding guidelines, “Avoid variable shadowing, especially
err.”🤖 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 `@pkg/version/retriever.go` around lines 105 - 107, Update the cache write error handling in the version retrieval flow to avoid shadowing the existing parser error variable: bind the result of r.cache.Set to a distinct cacheErr name and use that variable in the logger.Debugf call, preserving the current behavior.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@pkg/version/retriever_test.go`:
- Around line 20-30: Add focused fixture coverage around the version-parsing
test using expectedVersions and htmlContent: include a high-version link outside
tr.file and a latest/ link inside tr.file, then assert the parsed versions
exclude both while preserving the existing valid versions.
In `@pkg/version/retriever.go`:
- Around line 105-107: Update the cache write error handling in the version
retrieval flow to avoid shadowing the existing parser error variable: bind the
result of r.cache.Set to a distinct cacheErr name and use that variable in the
logger.Debugf call, preserving the current behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 8cb133ed-1182-48e2-bb4a-7e8375210c7d
⛔ Files ignored due to path filters (25)
go.sumis excluded by!**/*.sumvendor/github.com/PuerkitoBio/goquery/.gitattributesis excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/.gitignoreis excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/LICENSEis excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/README.mdis excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/array.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/doc.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/expand.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/filter.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/iteration.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/manipulation.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/property.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/query.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/traversal.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/type.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/PuerkitoBio/goquery/utilities.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/andybalholm/cascadia/.travis.ymlis excluded by!vendor/**,!**/vendor/**vendor/github.com/andybalholm/cascadia/LICENSEis excluded by!vendor/**,!**/vendor/**vendor/github.com/andybalholm/cascadia/README.mdis excluded by!vendor/**,!**/vendor/**vendor/github.com/andybalholm/cascadia/parser.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/andybalholm/cascadia/pseudo_classes.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/andybalholm/cascadia/selector.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/andybalholm/cascadia/serialize.gois excluded by!vendor/**,!**/vendor/**vendor/github.com/andybalholm/cascadia/specificity.gois excluded by!vendor/**,!**/vendor/**vendor/modules.txtis excluded by!vendor/**,!**/vendor/**
📒 Files selected for processing (3)
go.modpkg/version/retriever.gopkg/version/retriever_test.go
|
PR needs rebase. 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. |
PR Summary
Replace goquery HTML DOM parsing with a ~50-line golang.org/x/net/html tokenizer for extracting version links from the OpenShift mirror page. Promote golang.org/x/net from indirect to direct dependency.
Detailed Description of the Issue
Our ROSA CLI project currently imports several third-party libraries that are only utilized in a single file (e.g., exclusively within a test file or for a single validation function). Relying on entire external dependencies for isolated use cases unnecessarily increases our security attack surface, complicates dependency management, and bloats the project.
This PR is part of that initiative to remove
github.com/PuerkitoBio/goqueryRelated Issues and PRs
Type of Change
Previous Behavior
Query can parse the ROSA mirror page
Behavior After This Change
unchanged
How to Test (Step-by-Step)
Preconditions
Test Steps
make testExpected Results
All tests pass
Proof of the Fix
Breaking Changes
Breaking Change Details / Migration Plan
New query logic is more correct, as it will search
<tr class="file">elements instead of any HTML element with "file" class. The ROSA mirror page it searches has the files we are searching for undertrelementsDeveloper Verification Checklist
[JIRA-TICKET] | [TYPE]: <MESSAGE>.make install-hookshas been run in this clone.make testpasses.make lintpasses.make rosapasses.Summary by CodeRabbit
Bug Fixes
Tests