-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Clean the GO mod files by removing the unnecessary indirect imports #1454
Clean the GO mod files by removing the unnecessary indirect imports #1454
Conversation
edbc724
to
8ac09ae
Compare
/test pull-kubebuilder-e2e-k8s-1-16-2 |
My understanding of P.S.: Checking that tests pass in this case doesn't seem enough because probably none of those of those libraries made a backwards incompatible change so removing the indirect requirement may just get the last version and still work. But in case they make a backwards incompatible change it may break the build. |
/assign @mengqiy |
8ac09ae
to
f3f308d
Compare
d9555e8
to
f64df06
Compare
I'd trust the go modules to do the job of tracking necessary entries in the go.mod file. |
Hi @mengqiy, Unfortunately, See for example that "github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e" is not required in the main module.
Also, note that these indirect imports are just added when we run
Is it make sense @mengqiy? Are you ok with we clean it? |
Though we do Line 50 in 29d1dc1
go get in Line 63 in 29d1dc1
go get in a temp directory. This can avoid it messing up the go.mod file.
|
f64df06
to
c7e081e
Compare
HI @mengqiy, Now the go mod is clean the make generate target is fixed. I mean it will no longer install the indirect modules. |
.PHONY: generate-setup | ||
generate-setup: ## Current workarround to generate the testdata with the correct controller-gen version | ||
- rm -rf $(CONTROLLER_GEN_BIN_PATH) | ||
- GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/[email protected] |
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.
You don't need to remove this section. I imagine that what you can do here is
- create a temp directory (e.g. using https://golang.org/pkg/io/ioutil/#TempDir)
- cd to that directory
- run go get with go modules on
- cd to the previous working directory
- remove the temp dir.
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.
This makefile target was added just to ensure that the correct version will be used.
Note that we just need to remove any pre-existent installation to ensure that. And then, the defined version in the makefile which will be scaffolded will be installed and used. So, it is not required at all and because of this, I keep just the rm -rf line and did not the tmp dir. See: https://github.com/kubernetes-sigs/kubebuilder/pull/1454/files#diff-b67911656ef5d18c4ae36cb6741b7965R57 Is it make sense?
Makefile
Outdated
@@ -45,7 +52,9 @@ install: ## Build and install the binary with the current source code. Use it to | |||
|
|||
.PHONY: generate | |||
generate: ## Update/generate all mock data. You should run this commands to update the mock data after your changes. | |||
make generate-setup | |||
# if an controller-gen be locally installed already it will be removed to ensure that the generate will | |||
# get and use the correct version defined in the testdata makefiles instead of an previous installation. |
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.
This statement doesn't match what is done.
controller-gen is not installed after removing.
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.
HI @mengqiy.
See:
When we start the controller-gen removed
And then in it got in the by the scaffold files
And then the gen installed when it finishes.
So, what is your suggestion for the comment/explanation?
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.
Ha... You rely on the Makefile in the generated project to install the controller-gen for you.
I didn't realized it. It's not intuitive, but seems to be OK.
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.
Please update the comment here to reflect how it work.
Then it should be OK to go.
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.
Let me know if you are ok with the updates in the comment. Really tks for your review,
c7e081e
to
8985369
Compare
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, mengqiy 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 |
Description