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

switch dep to go mod and upgrade go version #67

Merged
merged 2 commits into from
Mar 23, 2020

Conversation

u2takey
Copy link
Contributor

@u2takey u2takey commented Feb 12, 2020

  1. use go mod for dependency management (for both main and examples).
  2. upgrade golang version to 1.13.

Fixes: #65

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

Welcome @u2takey!

It looks like this is your first PR to kubernetes-sigs/sig-storage-lib-external-provisioner 🎉. 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/sig-storage-lib-external-provisioner 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 k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Feb 12, 2020
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 12, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 12, 2020
@jsafrane
Copy link
Contributor

cc @wongma7 @pohly
It looks good, however, I don't understand go dependencies too much.

gometalinter --install
# todo gometalinter is DEPRECATED, Use https://github.com/golangci/golangci-lint
GO111MODULE=off go get -u github.com/alecthomas/gometalinter
GO111MODULE=off gometalinter --install
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be enhanced to get a fixed version of gometalinter while you are touching this code? Like depending on "master" for Kubernetes, depending on master of gometalinter (or golangci-lint) has the risk that changes in those project(s) break this project.

I know that this is more complicated because (for reasons that I don't understand) go get in non-module mode doesn't support specifying a version, but perhaps it works when adding it as module and then building?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

with GO111MODULE=off its not easy, but we can fix it later by replacing with golangci-lint. In fact gometalinter is DEPRECATED, so its 'fixed'.

go.mod Outdated
@@ -0,0 +1,17 @@
module sigs.k8s.io/sig-storage-lib-external-provisioner
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the next release with this change will have to be v5.0.0 because introducing Go module support is a breaking change. Also, because the major version is > 1, versioned imports become mandatory.

This means that sigs.k8s.io/sig-storage-lib-external-provisioner has to be replaced with sigs.k8s.io/sig-storage-lib-external-provisioner/v5 here and in all import statements in the code itself.

This also raises the question whether importing with dep is still supposed to work. It doesn't out-of-the-box anymore because dep doesn't understand versioned imports.

We worked around that with symlinks elsewhere, see kubernetes-csi/external-attacher#209 and kubernetes-csi/csi-test#232.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a single commit is added to fix this.

Copy link
Contributor

Choose a reason for hiding this comment

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

The commit message of that commit ("add compatibility with dep") misses the main reason for doing this: "go mod" will also refuse to pull the code unless the /v5 suffix matches the major version number.

Not sure whether you want to fix that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

git message amended.

Copy link
Contributor

Choose a reason for hiding this comment

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

I probably explained this wrong 😁

The "/v5" suffix isn't needed by dep, quite the opposite, it just gets confused by it. It's needed by "go mod". Anyway, let's leave the commit message as-is.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, I'm new to this pattern. I just read https://blog.golang.org/v2-go-modules and in their example they don't symlink, instead they keep v0/v1 in the top-level and they let all the versions coexist in the same branch.

I don't want to follow that example because this library makes breaking changes quite often and it would be a pain to retroactively make v2-v5 directories.

But I think symlinking could get pretty tedious as well. If I want to refactor and add/delete a file, I need to make sure the symlink under /v5 is updated accordingly? Is there a common script all our repos could share that could make validation & maintenance of these symlinks easier?

Copy link
Contributor

Choose a reason for hiding this comment

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

What happens when I want to release a v6? Would I simply rename v5 to v6?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't want to follow that example because this library makes breaking changes quite often and it would be a pain to retroactively make v2-v5 directories.

I agree, having multiple different versions in the same branch looks awkward. It's probably only relevant if developers really need to support multiple API versions.

Symlinking is a stop-gap measure to continue supporting dep. I don't know how important that is for the consumers of this library. It is something that could be scripted, but there is no script at the moment.

What happens when I want to release a v6? Would I simply rename v5 to v6?

Yes.

Copy link
Contributor

@pohly pohly left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot
Copy link
Contributor

@pohly: changing LGTM is restricted to collaborators

In response to this:

/lgtm

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.

@jsafrane
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 Mar 23, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jsafrane, u2takey

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 Mar 23, 2020
@k8s-ci-robot k8s-ci-robot merged commit 7d9e8b4 into kubernetes-sigs:master Mar 23, 2020
humblec pushed a commit to humblec/sig-storage-lib-external-provisioner that referenced this pull request Jun 18, 2020
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.

Use go modules
5 participants