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

🌱 Replace ioutil with os/io packages, run gofmt #5533

Merged
merged 1 commit into from
Oct 29, 2021

Conversation

ahrtr
Copy link
Contributor

@ahrtr ahrtr commented Oct 29, 2021

The ioutil package has already been deprecated in golang 1.16, please see go1.16#ioutil. So we need to replace all the ioutil with os and io.

This PR also contains two changes made by gofmt automatically.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 29, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @ahrtr!

It looks like this is your first PR to kubernetes-sigs/cluster-api 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @ahrtr. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 29, 2021
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 29, 2021
@enxebre
Copy link
Member

enxebre commented Oct 29, 2021

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 29, 2021
@enxebre
Copy link
Member

enxebre commented Oct 29, 2021

/retitle 🌱 Replace ioutil with os and io

@k8s-ci-robot k8s-ci-robot changed the title Replace ioutil with os and io 🌱 Replace ioutil with os and io Oct 29, 2021
… we need to replace ioutil with os.

A couple of gofmt warnings are also fixed in this PR.
Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will a go mod why work for a built in package? Just trying to make sure we have all occurrences within our own packages

Alternatively, is there a one shot we can run to verify that none of the files are importing this package now?

@@ -16,5 +16,5 @@ limitations under the License.

package v1beta1

func (*DockerMachinePool) Hub() {}
func (*DockerMachinePoolList) Hub() {}
func (*DockerMachinePool) Hub() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems unrelated to this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES, it's fixed automatically by gofmt -w .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why we're not enforcing gofmt on this file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be the version rendering differently

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I configure my local go version to 1.16.7 on purpose, so as to be consistent with the version in go.mod.

$ go version
go version go1.16.7 darwin/amd64

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the go version is fine (otherwise the verify job would fail).

I think gofmt is not enforced in the test go module (same for hacks)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just ran gofmt.-w . on a linux vm, and it has the same result as my Mac.

$ go version
go version go1.16.9 linux/amd64

@@ -22,10 +22,10 @@ package tools
import (
_ "github.com/drone/envsubst/v2/cmd/envsubst"
_ "github.com/joelanford/go-apidiff"
_ "github.com/mikefarah/yq/v4"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems unrelated to this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES, it's fixed automatically by gofmt -w .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gofmt usually doesn't reorder imports, are you using goimports instead or some other formatter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does:

$ which gofmt
/usr/local/opt/go@1.16/bin/gofmt

gofmt -w ./hack/tools/tools.go

git diff
diff --git a/hack/tools/tools.go b/hack/tools/tools.go
index 792e899d1..248cc707c 100644
--- a/hack/tools/tools.go
+++ b/hack/tools/tools.go
@@ -22,10 +22,10 @@ package tools
 import (
        _ "github.com/drone/envsubst/v2/cmd/envsubst"
        _ "github.com/joelanford/go-apidiff"
+       _ "github.com/mikefarah/yq/v4"
        _ "github.com/onsi/ginkgo/ginkgo"
        _ "gotest.tools/gotestsum"
        _ "k8s.io/code-generator/cmd/conversion-gen"
        _ "sigs.k8s.io/controller-runtime/tools/setup-envtest"
        _ "sigs.k8s.io/controller-tools/cmd/controller-gen"
-       _ "github.com/mikefarah/yq/v4"
 )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought that only goimports does anything to the imports.

@fabriziopandini
Copy link
Member

/lgtm
I would suggest to drop changes not related to this PR, but I want block on this.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 29, 2021
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vincepri

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 29, 2021
@vincepri
Copy link
Member

/retitle 🌱 Replace ioutil with os/io packages, run gofmt

@k8s-ci-robot k8s-ci-robot changed the title 🌱 Replace ioutil with os and io 🌱 Replace ioutil with os/io packages, run gofmt Oct 29, 2021
@k8s-ci-robot k8s-ci-robot merged commit 0e64281 into kubernetes-sigs:main Oct 29, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.1 milestone Oct 29, 2021
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants