-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop using deprecated ioutil functions #4754
Conversation
Thank you so much for working on this massive cleanup! |
Finally figured out why none of us were seeing this locally: it's a Go version problem. CI uses at least version 1.18, and a few days ago started using 1.19. In 1.18, these ioutil methods have textual warnings around them; in 1.19, they have the markers the linter can detected. They were added in this commit: golang/go@a208aa7 |
@KnVerey: This PR has multiple commits, and the default merge method is: merge. 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/test-infra repository. |
func (fsOnDisk) ReadFile(name string) ([]byte, error) { return ioutil.ReadFile(name) } | ||
// ReadFile delegates to os.ReadFile. | ||
func (fsOnDisk) ReadFile(name string) ([]byte, error) { | ||
//nolint:wrapcheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: I can't wrap this because kyaml errors does not have proper Is
support until the dependency bump in #4727 merges
ok, this is finally 🟢 , PTAL @natasha41575 |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: KnVerey, natasha41575 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The only one that is not a direct replacement with exactly the internals of the ioutil function is
os.ReadDir
: https://cs.opensource.google/go/go/+/refs/tags/go1.19:src/io/ioutil/ioutil.go;l=49-81. We were only using that one in two places, one of which is a test and the other of which is a utility (cmd/mdtogo/main.go); I read the surrounding code in both and the replacement seems fine.This should see the staticcheck linter error all PRs are seeing in CI right now.
I'm still looking into why we can't reproduce the linter error locally, and why it started in CI this week on a LOC last modified 4 months ago (and none of the many other places this PR shows we are using deprecated ioutil functions).This started happening when CI upgraded itself to Go 1.19, which contains golang/go@a208aa7, allowing the linter to detect this stdlib deprecation.Closes #4760