-
Notifications
You must be signed in to change notification settings - Fork 148
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
Fix go module requirements for semantic versioning #232
Conversation
As stated in this blog post: https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher modules that release a version higher than 1 need to put the version into the package path.
Hi @Ntr0. Thanks for your PR. I'm waiting for a kubernetes-csi or kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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. |
v3.0.0 fixed "go mod" support by adding the /v3 suffix to import paths (kubernetes-csi/csi-test#232). dep currently does not support that (golang/dep#1962 (comment)) and can only import that with symlink workarounds in csi-test and by disabling pruning.
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 breaks vendoring csi-test
with dep
because of golang/dep#1962.
I don't want to force all consumers of csi-test to switch to go mod
. I don't like the proposal with "Major subdirectory" from https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher either because it is so intrusive for the git history.
I came up with another solution based on symlinks, see pohly@2bc889d. I verified that this then can be imported with dep (pohly/pmem-CSI@79b03e9), albeit only with a small trick (disabling pruning for csi-test).
@Ntr0: what do you think of that approach? Can you verify that 'go modignores this new
/v3` sub-directory?
If you agree that this is acceptable and works, please cherry-pick my commit into your branch.
These symlinks ensure that "dep" can still import v3.0.0. Without them, importing fails when it encounters the github.com/kubernetes-csi/csi-test/v3 because there's no code under that path without the symlinks. Symlinks work for files, but not for directories (probably due to a check in dep which expects directories for packages). Upstream suggests to move the code itself ("Major subdirectory", https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher). But that messes with git history. Symlinks are simpler, but have the disadvantage of only working on Unix. Users on Windows will have to use "go mod" for importing.
@pohly It looks like it works. This approach seems reasonable to me, as I won't expect csi-test to maintain different versions of the package. So keeping the semantic version in the main go.mod and having these symlinks looks good to me. |
Doesn't git mv retain history? |
/ok-to-test |
Michelle Au <[email protected]> writes:
> it is so intrusive for the git history
Doesn't git mv retain history?
"git mv" is the same as deleting a file and adding it under a different
name. It doesn't have any special support for keeping history. This is
all handled when analyzing the commits: some operations detect such
renames and follow them, some don't.
For example, "git log v3" would stop at the commit that introduced the
directory. "git log v3/pkg/sanity/sanity.go" would work.
|
Seems fine to me if the file still retains history. We rename files in k/k often. I think it's kind of messy and confusing to have symlinks |
There are other drawbacks, like having to maintain the
It's an interim solution until either "dep" gets enhanced (PR is pending) or we can convince ourselves that supporting "dep" isn't necessary anymore. I prefer symlinks over messing with the directory structure. |
If there's no consensus on how to support "dep", then I propose that we simply don't do anything special to support it, i.e. remove 0163355 from this PR again. Then "dep" users either have to switch to "go mod" or use a patched dep version (golang/dep#1963). |
/lgtm |
Can you also add a release note indicating the potential future version of dep that will be needed? |
It seems uncertain which version of dep will have golang/dep#1963 included; might be a patch or a major release. Better link to the PR. |
@pohly Updated Release Notes to point out the breaking change for dep users |
Sorry for the back and forth, but when we discussed this yesterday in the Kubernetes-CSI standup meeting, @msau42 said that we should continue to support importing with normal dep. We settled on the approach with symlinks as the lesser evil. Can you remove the revert commit from your branch and augment my commit with the following
Can you also adapt the release note accordingly? Thanks! |
The double revert looks a bit weird, personally I would use |
Wait, the release note still needs to be updated:
=>
|
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: msau42, Ntr0 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 |
As stated in this post:
https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher
modules that released a version higher than 1 need to put the version
into the package path.
What type of PR is this?
/kind bug
What this PR does / why we need it:
When 2.3.0 introduced go modules, the package paths where not updated. Therefore
this module cannot be imported as version 2.3.0 since go mod will complain:
go.mod:12: require github.com/kubernetes-csi/csi-test: version "v2.3.0" invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2
Which issue(s) this PR fixes:
Fixes #231
Special notes for your reviewer:
Does this PR introduce a user-facing change?: