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

[TEST] Switch to go modules #3308

Closed
wants to merge 1 commit into from
Closed

Conversation

crazy-max
Copy link
Member

@crazy-max crazy-max commented Sep 24, 2021

Signed-off-by: CrazyMax crazy-max@users.noreply.github.com

- What I did

Switch to go modules

- How I did it

go mod init github.com/docker/cli outside GOPATH and translate replacements from vendor.conf

- How to verify it

# update vendor
make -f docker.Makefile vendor
# validate vendor
make -f docker.Makefile validate-vendor
# test build
make -f docker.Makefile binary

(bonus) check outdated dependencies:

$ make -f docker.Makefile mod-outdated
#13 3.293 +--------------------------------------+-----------------------------------------------------+------------------------------------+--------+------------------+
#13 3.293 |                MODULE                |                       VERSION                       |            NEW VERSION             | DIRECT | VALID TIMESTAMPS |
#13 3.293 +--------------------------------------+-----------------------------------------------------+------------------------------------+--------+------------------+
#13 3.293 | github.com/containerd/console        | v1.0.2                                              | v1.0.3                             | true   | true             |
#13 3.293 | github.com/creack/pty                | v1.1.11                                             | v1.1.15                            | true   | true             |
#13 3.294 | github.com/docker/docker             | v20.10.3-0.20210811141259-343665850e3a+incompatible |                                    | true   | true             |
#13 3.294 | github.com/google/go-cmp             | v0.5.5                                              | v0.5.6                             | true   | true             |
#13 3.294 | github.com/imdario/mergo             | v0.3.11                                             | v0.3.12                            | true   | true             |
#13 3.294 | github.com/mitchellh/mapstructure    | v1.3.2                                              | v1.4.2                             | true   | true             |
#13 3.294 | github.com/moby/buildkit             | v0.8.2-0.20210615162540-9f254e18360a                | v0.9.0                             | true   | true             |
#13 3.294 | github.com/spf13/cobra               | v1.1.3                                              | v1.2.1                             | true   | true             |
#13 3.295 | github.com/theupdateframework/notary | v0.7.1-0.20210315103452-bf96a202a09a                |                                    | true   | true             |
#13 3.295 | github.com/tonistiigi/fsutil         | v0.0.0-20210609172227-d72af97c0eaf                  | v0.0.0-20210921173121-89d411606598 | true   | true             |
#13 3.295 | github.com/tonistiigi/go-rosetta     | v0.0.0-20200727161949-f79598599c5d                  | v0.0.0-20201102221648-9ba854641817 | true   | true             |
#13 3.295 | golang.org/x/sys                     | v0.0.0-20210823070655-63515b42dcdf                  | v0.0.0-20210923061019-b8560ed6a9b7 | true   | true             |
#13 3.295 | golang.org/x/term                    | v0.0.0-20201117132131-f5c789dd3221                  | v0.0.0-20210916214954-140adaaadfaf | true   | true             |
#13 3.295 | golang.org/x/text                    | v0.3.3                                              | v0.3.7                             | true   | true             |
#13 3.296 | k8s.io/api                           | v0.16.9                                             | v0.22.2                            | true   | true             |
#13 3.296 | k8s.io/apimachinery                  | v0.16.9                                             | v0.22.2                            | true   | true             |
#13 3.296 | k8s.io/client-go                     | v0.16.9                                             | v1.5.2                             | true   | true             |
#13 3.296 +--------------------------------------+-----------------------------------------------------+------------------------------------+--------+------------------+
#13 DONE 3.3s

- A picture of a cute animal (not mandatory but encouraged)

@crazy-max crazy-max force-pushed the gomod branch 2 times, most recently from ac0d501 to 714bc32 Compare September 24, 2021 20:24
@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2021

Codecov Report

Merging #3308 (c1c56e6) into master (47e5cfa) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #3308   +/-   ##
=======================================
  Coverage   57.99%   57.99%           
=======================================
  Files         302      302           
  Lines       21764    21764           
=======================================
  Hits        12621    12621           
  Misses       8219     8219           
  Partials      924      924           

@crazy-max crazy-max force-pushed the gomod branch 5 times, most recently from 103604d to b479e94 Compare September 27, 2021 13:07
@@ -0,0 +1,91 @@
module github.com/docker/cli
Copy link
Member

Choose a reason for hiding this comment

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

This is the tricky bit.

Using go modules for this repository itself is generally not problematic, but but for anyone using the cli as a dependency, things are more complicated.

The module is named github.com/docker/cli, but Go will refuse to use it under that name if there's a go.mod, because the current version is v20.10.x, so it will require the packages to be renamed to github.com/docker/cli/v20.

That "works" if we release once a year, but if we would do multiple releases, it will be complicated. Tags on this repository are for the binary releases, which use CalVer, not SemVer, but "sometimes" the format is "compatible" (any release done in October, November or December, because then the second digit will start with a 1. However, that would put v21.10.0 and v21.11.0 both to be github.com/docker/cli/v21, and with a go.mod, you add the promise that it's SemVer, so no breaking changes allowed in between.

Releases before October each year would also not be picked up by go modules (the v22.01.0 version string is not in the correct format for SemVer, so will be ignored).

Copy link
Member Author

@crazy-max crazy-max Sep 27, 2021

Choose a reason for hiding this comment

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

Yes, indeed, if we follow our versioning practice (CalVer), it's unfortunately not affordable.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants