Skip to content

[TEST] Switch to go modules - #3308

Closed
crazy-max wants to merge 1 commit into
docker:masterfrom
crazy-max:gomod
Closed

[TEST] Switch to go modules#3308
crazy-max wants to merge 1 commit into
docker:masterfrom
crazy-max:gomod

Conversation

@crazy-max

@crazy-maxcrazy-max commented Sep 24, 2021

Copy link
Copy Markdown
Member

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-maxforce-pushed the gomod branch 2 times, most recently from ac0d501 to 714bc32CompareSeptember 24, 2021 20:24
@codecov-commenter

codecov-commenter commented Sep 24, 2021

Copy link
Copy Markdown

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-maxforce-pushed the gomod branch 5 times, most recently from 103604d to b479e94CompareSeptember 27, 2021 13:07
Comment threadgo.mod
@@ -0,0 +1,91 @@
module github.com/docker/cli

Copy link
Copy Markdown
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).

@crazy-maxcrazy-maxSep 27, 2021

Copy link
Copy Markdown
MemberAuthor

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 freeto 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

@crazy-max@codecov-commenter@thaJeztah