CNF-23377: Migrate away from deprecated ioutil#490
Conversation
56f78af to
407f195
Compare
|
Issues go stale after 90d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle stale |
407f195 to
adcb7ed
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (20)
✅ Files skipped from review due to trivial changes (6)
🚧 Files skipped from review as they are similar to previous changes (14)
WalkthroughThis PR replaces deprecated io/ioutil usage across the build package by switching to os package equivalents (ReadFile, WriteFile, CreateTemp, MkdirTemp, ReadDir), preserving existing control flow and error handling. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (2 errors, 1 warning)
✅ Passed checks (12 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/build/builder/cmd/scmauth/scmauths.go (1)
55-60:⚠️ Potential issue | 🔴 Critical
os.ReadDirreturn type mismatchespresentsignature (build break).
os.ReadDirreturns[]os.DirEntry, butpresentat line 23 accepts[]os.FileInfo. The calls at line 60 (and line 40 in scmauths_test.go) will not compile.Change the
presentsignature from[]os.FileInfoto[]os.DirEntry—the function only callsName(), which exists on both types.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/build/builder/cmd/scmauth/scmauths.go` around lines 55 - 60, The build breaks because present currently accepts []os.FileInfo while os.ReadDir returns []os.DirEntry; update the present function signature (present) to accept []os.DirEntry instead of []os.FileInfo and adjust any callers (e.g., the present(files) call and the test that passes directory listings) so they pass the DirEntry slice; no other logic changes are needed since present only calls Name() which exists on both types.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@pkg/build/builder/cmd/scmauth/scmauths.go`:
- Around line 55-60: The build breaks because present currently accepts
[]os.FileInfo while os.ReadDir returns []os.DirEntry; update the present
function signature (present) to accept []os.DirEntry instead of []os.FileInfo
and adjust any callers (e.g., the present(files) call and the test that passes
directory listings) so they pass the DirEntry slice; no other logic changes are
needed since present only calls Name() which exists on both types.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: ec876062-ca39-458a-8f62-f2fa2af5aeb7
📒 Files selected for processing (20)
pkg/build/builder/cmd/dockercfg/cfg.gopkg/build/builder/cmd/dockercfg/cfg_test.gopkg/build/builder/cmd/scmauth/cacert.gopkg/build/builder/cmd/scmauth/password.gopkg/build/builder/cmd/scmauth/scmauth_test.gopkg/build/builder/cmd/scmauth/scmauths.gopkg/build/builder/cmd/scmauth/scmauths_test.gopkg/build/builder/cmd/scmauth/sshkey.gopkg/build/builder/cmd/scmauth/sshkey_test.gopkg/build/builder/cmd/scmauth/util.gopkg/build/builder/common.gopkg/build/builder/common_test.gopkg/build/builder/daemonless.gopkg/build/builder/daemonless_test.gopkg/build/builder/docker_test.gopkg/build/builder/dockerutil_test.gopkg/build/builder/source.gopkg/build/builder/source_test.gopkg/build/builder/sti.gopkg/build/builder/util_linux.go
adcb7ed to
e6c9462
Compare
|
@sebrandon1: This pull request references CNF-23377 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. |
|
/remove-lifecycle stale |
|
/retest |
|
/retest |
e6c9462 to
9fc7571
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sebrandon1 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 |
|
@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. |
ioutilhas been deprecated since Go 1.16: https://go.dev/doc/go1.16#ioutilTracking issue: redhat-best-practices-for-k8s/telco-bot#52
Migration from
ioutiltoospackage:File and directory operations:
Replaced all instances of
ioutil.ReadFile,ioutil.WriteFile, andioutil.ReadDirwithos.ReadFile,os.WriteFile, andos.ReadDirrespectively throughout the codebase, including files likecfg.go,scmauths.go,sshkey.go,common.go, and their associated test files. [1] [2] [3] [4] [5] [6] [7] [8] [9]Updated all usages of
ioutil.TempFileandioutil.TempDirtoos.CreateTempandos.MkdirTemprespectively, ensuring temporary files and directories are created using the recommended APIs. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]Imports and cleanup:
ioutilimports and replaced them with appropriateosimports in all affected files. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]These changes ensure the project is compatible with newer Go versions and avoids deprecated functionality.
Summary by CodeRabbit