Skip to content
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

Merged
merged 2 commits into from Aug 16, 2022

Conversation

KnVerey
Copy link
Contributor

@KnVerey KnVerey commented Aug 10, 2022

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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 10, 2022
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 10, 2022
@natasha41575
Copy link
Contributor

Thank you so much for working on this massive cleanup!

@KnVerey
Copy link
Contributor Author

KnVerey commented Aug 10, 2022

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

@k8s-ci-robot
Copy link
Contributor

@KnVerey: This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

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
Copy link
Contributor Author

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

@KnVerey
Copy link
Contributor Author

KnVerey commented Aug 10, 2022

ok, this is finally 🟢 , PTAL @natasha41575

@natasha41575
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 16, 2022
@k8s-ci-robot
Copy link
Contributor

[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:
  • OWNERS [KnVerey,natasha41575]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 2ec4b97 into kubernetes-sigs:master Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint Errors on Github repo
3 participants