aws / amazon-ecs-init

Amazon Elastic Container Service RPM
http://aws.amazon.com/ecs
Apache License 2.0
200 stars 118 forks source link

Migrate from dep to go modules for dependency management #396

Closed jfkw closed 3 years ago

jfkw commented 3 years ago

Summary

Migrate from dep dependency manager to go modules to assist packagers.

Description

aws/amazon-ecs-init uses dep dependency manger instead of go modules. Conducting a migration at this time would be helpful. go1.16 changes the environment variable GO111MODULE default from auto to on. With this change, users building with go1.16 need to set GO111MODULE to auto to build as before. In a future version of go1.x support for GOPATH will be removed, so the migration needs to happen eventually. For some distributions, there is also automated tooling for go modules, that is not available for continued use of dep.

EDIT: For best usability with go tools, a migration to use go modules may also benefit from changes to the source layout so that go.mod go.sum are at the root of the published import path, i.e. the root of this repository. Acknowledged that source moves are a non-trivial change to be considered.

Expected Behavior

aws/amazon-ecs-init builds as before with versions of go1.16+

Observed Behavior

aws/amazon-ecs-init build fails with go1.16 unless GO111MODULE is changed from the new default.

Environment Details

GO111MODULE=""
GOARCH="amd64"
GOVERSION="go1.16.2"

Supporting Log Snippets

A test run of go mod init converts from dep with the following minor issues reported:

$ go mod init aws/amazon-ecs-init
go: creating new go.mod: module aws/amazon-ecs-init
go: converting Gopkg.lock: stat github.com/coreos/go-systemd@v22.0.0: github.com/coreos/go-systemd@v22.0.0: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v22
go: copying requirements from Gopkg.lock
go: to add module requirements and sums:
        go mod tidy

$ go mod tidy
go: downloading github.com/stretchr/testify v1.2.2
go: downloading github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575
go: downloading github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129
go: downloading github.com/aws/aws-sdk-go v1.36.0
go: downloading github.com/fsouza/go-dockerclient v0.0.0-20170830181106-98edf3edfae6
go: downloading github.com/NVIDIA/gpu-monitoring-tools v0.0.0-20180829222009-86f2a9fac6c5
go: downloading github.com/docker/go-plugins-helpers v0.0.0-20181025120712-1e6269c305b8
go: downloading github.com/Microsoft/go-winio v0.4.2
go: downloading github.com/docker/docker v1.4.2-0.20170530175538-4f55e390c4e5
go: downloading github.com/docker/go-units v0.3.2
go: downloading github.com/docker/go-connections v0.2.2-0.20170331145122-e15c02316c12
go: downloading github.com/Sirupsen/logrus v0.11.6-0.20170515105910-5e5dc898656f
go: downloading github.com/opencontainers/runc v1.0.0-rc3.0.20170530161907-a6906d5a531a
go: downloading github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5
go: downloading github.com/Azure/go-ansiterm v0.0.0-20160622173216-fa152c58bc15
go: downloading github.com/opencontainers/image-spec v1.0.0-rc6.0.20170525204040-4038d4391fe9
go: downloading github.com/opencontainers/go-digest v1.0.0-rc0.0.20170510163354-eaa60544f31c
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/engine
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/docker
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/config
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/exec
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/version
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/gpu
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/backoff
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/cache
go: downloading github.com/aws/amazon-ecs-init v1.25.3
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/exec/iptables
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/exec/sysctl
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/cmd
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/volumes/logger
go: finding module for package github.com/google/go-cmp/cmp
go: finding module for package github.com/coreos/go-systemd/activation
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/volumes
go: downloading github.com/google/go-cmp v0.5.5
go: downloading github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
go: found github.com/aws/amazon-ecs-init/ecs-init/config in github.com/aws/amazon-ecs-init v1.25.3
go: found github.com/aws/amazon-ecs-init/ecs-init/engine in github.com/aws/amazon-ecs-init v1.25.3
go: found github.com/aws/amazon-ecs-init/ecs-init/version in github.com/aws/amazon-ecs-init v1.25.3
go: found github.com/aws/amazon-ecs-init/ecs-init/backoff in github.com/aws/amazon-ecs-init v1.25.3
go: found github.com/aws/amazon-ecs-init/ecs-init/gpu in github.com/aws/amazon-ecs-init v1.25.3
go: found github.com/aws/amazon-ecs-init/ecs-init/cache in github.com/aws/amazon-ecs-init v1.25.3
go: found github.com/aws/amazon-ecs-init/ecs-init/docker in github.com/aws/amazon-ecs-init v1.25.3
go: found github.com/aws/amazon-ecs-init/ecs-init/exec in github.com/aws/amazon-ecs-init v1.25.3
go: found github.com/aws/amazon-ecs-init/ecs-init/exec/iptables in github.com/aws/amazon-ecs-init v1.25.3
go: found github.com/aws/amazon-ecs-init/ecs-init/exec/sysctl in github.com/aws/amazon-ecs-init v1.25.3
go: found github.com/aws/amazon-ecs-init/ecs-init/cmd in github.com/aws/amazon-ecs-init v1.25.3
go: found github.com/google/go-cmp/cmp in github.com/google/go-cmp v0.5.5
go: found github.com/coreos/go-systemd/activation in github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/volumes/logger
go: finding module for package github.com/aws/amazon-ecs-init/ecs-init/volumes
aws/amazon-ecs-init/volumes/amazon-ecs-volume-plugin imports
        github.com/aws/amazon-ecs-init/ecs-init/volumes: module github.com/aws/amazon-ecs-init@latest found (v1.25.3), but does not contain package github.com/aws/amazon-ecs-init/ecs-init/volumes
aws/amazon-ecs-init/volumes/amazon-ecs-volume-plugin imports

        github.com/aws/amazon-ecs-init/ecs-init/volumes/logger: module github.com/aws/amazon-ecs-init@latest found (v1.25.3), but does not contain package github.com/aws/amazon-ecs-init/ecs-init/volumes/logger

With the final result:

$ cat go.mod
module aws/amazon-ecs-init

go 1.16

require (
        github.com/Azure/go-ansiterm v0.0.0-20160622173216-fa152c58bc15
        github.com/Microsoft/go-winio v0.4.2
        github.com/NVIDIA/gpu-monitoring-tools v0.0.0-20180829222009-86f2a9fac6c5
        github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5
        github.com/Sirupsen/logrus v0.11.6-0.20170515105910-5e5dc898656f
        github.com/aws/aws-sdk-go v1.36.0
        github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575
        github.com/davecgh/go-spew v1.1.1
        github.com/docker/docker v1.4.2-0.20170530175538-4f55e390c4e5
        github.com/docker/go-connections v0.2.2-0.20170331145122-e15c02316c12
        github.com/docker/go-plugins-helpers v0.0.0-20181025120712-1e6269c305b8
        github.com/docker/go-units v0.3.2
        github.com/fsouza/go-dockerclient v0.0.0-20170830181106-98edf3edfae6
        github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129
        github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
        github.com/opencontainers/go-digest v1.0.0-rc0.0.20170510163354-eaa60544f31c
        github.com/opencontainers/image-spec v1.0.0-rc6.0.20170525204040-4038d4391fe9
        github.com/opencontainers/runc v1.0.0-rc3.0.20170530161907-a6906d5a531a
        github.com/pkg/errors v0.8.1-0.20170505043639-c605e284fe17
        github.com/pmezard/go-difflib v1.0.0
        github.com/stretchr/testify v1.2.2
        golang.org/x/net v0.0.0-20170529214944-3da985ce5951
        golang.org/x/sys v0.0.0-20170529185110-b90f89a1e7a9
)
mythri-garaga commented 3 years ago

We are currently blocked on migrating to Go Modules by issues related to versioning. Closing this for now as this is not on our roadmap.