-
Notifications
You must be signed in to change notification settings - Fork 399
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
🏃 ⚠ Support for Go modules #175
🏃 ⚠ Support for Go modules #175
Conversation
This involves just a `go mod init sigs.k8s.io/controller-tools`. Before vendoring or tidying our new depenendecies, we must first get the project to build.
From within the testData project: ``` $ go mod init sigs.k8s.io/controller-tools/pkg/crd/generator/testData $ go get -m k8s.io/api@kubernetes-1.13.4 # pin api versions $ go get -m k8s.io/apimachinery@kubernetes-1.13.4 $ go build -o manager ./cmd/manager/ $ go mod tidy ```
The repo/module name is now read from a PROJECT file in the repo the generator is run against. It must be present.
- golangci-lint has feature parity, and is a lot quicker too. - gometalinter is deprecated and doesn't work nicely with Go modules.
- Use Go 1.12 - Get rid of dep in favor of Go modules - Get rid of golint and gometalinter in favor of golangci-lint
Now that the project can be built and the tests pass, we do a `go mod vendor` followed by a `go mod tidy`.
/assign @DirectXMan12 |
/assign @Mengqi |
@droot: GitHub didn't allow me to assign the following users: mengqi. Note that only kubernetes-sigs members and repo collaborators can be assigned and that issues/PRs can only have 10 assignees at the same time. In 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 kubernetes/test-infra repository. |
@andreykaipov I am not much familiar with |
Yup! The only commit in this PR that changes the logic of a generator is 626472c. Instead of validating the project to be under the GOPATH, it validates a PROJECT file exists. Then, instead of using The goal after this is to get Kubebuilder to use Go modules too (kubernetes-sigs/kubebuilder#506) 😄 |
@andreykaipov IIUC it require |
Setting The change is backwards compatible as long as users of Kubebuilder do not delete the generated PROJECT file. That's where |
Go modules plans on replacing dep entirely, is there need to be backwards compatible there? Most kubernetes projects now have tags to map to kubernetes versions, would it be possible to integrate these mappings, eg. |
|
So here's how I'm confirming the changes are backwards compatible. We'll create a new project with Kubebuilder, and then manually apply the changes from 626472c to the respective files in our vendor folder. Create a new project, run
Now manually apply the changes from 626472c to Confirm
Alternatively, run
|
@andreykaipov It's not a breaking change from user perspective. That's great. My only concern now is: if I'm a contributor to controller-tools, I'm in |
@mengqiy That's a good idea. I can add a Development section to the README explaining that. Edit: okiedoke - added it in 89d33b3. I think Go modules will become the default in Go 1.13 (see golang/go#27227), so we could probably remove the note once that happens. 😄 |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: andreykaipov 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 |
Hold the phone. People vendoring this with dep won't get dependency info out of this any more. I think we have to maintain a Gopkg.toml for a bit. At least until Go 1.13. |
We also have to make sure they stay up to date. |
Sorry, what do you mean by not being able to get the dependency info if vendoring with dep? Taking the Kubebuilder project as an example, I'm able to run a |
This issue may happen if the users don't use kubebuilder, but use controller-runtime and controller-tools directly. |
This PR adds support for Go modules, both from a development and consumer point of view.
Development still works from within the GOPATH, but
GO111MODULE=on
must be set when running tests.In addition, the CRD generator can now be run from outside of the GOPATH, so long as the project it's running against specifies the repo/module name in a PROJECT file.
I've also replaced gometalinter with golangci-lint in the test script as the former is deprecated and doesn't work with Go modules, while the latter does and has feature parity.
To make the review less of a headache, I've left the re-vendoring in a separate commit.
Please let me know if I missed anything!