-
Notifications
You must be signed in to change notification settings - Fork 618
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
migrate from dep to go module #2890
Conversation
notes: * dependencies autogenerated by go mod from dep do not always match the previous, so this change explicitly pinned some packages to the specific version that they were at before the migration, and no depedency version is changed as a result; * there are some changes in the vendor folder despite the dependency version did not change, including: (1) non go source file, for some reason dep pulls more of them than `go mod vendor`; (2) go source file with build tag +ignore, which `go mod vendor` does not pull; (3) file permission change, `go mod vendor` ignores execute permission of file being pulled; * the go build tools used in our ci such as staticcheck, gocyclo, goimports etc are not migrated to go mod as part of the change, because they are not managed by dep before hence not included in the dep to go mod migration.
* vendor mockgen/model package explicitly. this package is required in order to generate code with mockgen, but it's not automatically vendored with the golang/mock dependency. this commit makes sure the model package is vendored. * turn off go mod when running version-gen.go. otherwise the build script can fail in container due to no network access.
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.
\o/
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.
wonder what is causing some of the file perm changes
|
||
DEP_VERSION=v0.5.0 | ||
.PHONY: get-dep | ||
get-dep: bin/dep |
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.
👋
@@ -0,0 +1,80 @@ | |||
module github.com/aws/amazon-ecs-agent/agent |
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.
Welcome go mod!!
golang/go#34965 and the comments in it should explain |
Summary
Migrate dependency management from dep to go module.
Implementation details
This is based on #2647 but with the following differences, mainly to reduce the scope of the change:
The change consists of three parts. Below describes them in details.
Commit 1. Generate and vendor dependencies with go mod based on the one specified from dep (i.e. Gopkg.toml and Gopkg.lock)
This change is made via doing the following steps on top of dev branch:
Env: go 1.12.17 on a mac (using go 1.12 because agent built with go>=1.13 has issue on windows, the investigation of which is still tbd)
Steps:
go.sum
generated without version override and the existing Gopkg.lock file for each of the dependency we have. an override is added for each mismatch found between the two files):agent/vendor/modules.txt
(generated bygo mod vendor
, also added in this pr) and the Gopkg.lock (dependency version used by dep) file, go through each dependency, make sure it has same version/commit between the two files.There are some changes in the vendor folder despite the dependency version did not change. Changes consist of three types: (1) non go source file (e.g.
.md
file, license file, binary), for some reason dep pulls more of them thango mod vendor
; (2) go source file with build tag +ignore, whichgo mod vendor
does not pull; (3) file permission change,go mod vendor
ignores execute permission of file being pulled, according to golang/go#34965 (comment) this is expected. My understanding is these changes should not affect the build (otherwise it would be a bug in go).Commit 2. remove dep files and related make target after migrating to go mod
This part should be obvious.
Commit 3. fix mockgen and version-gen after migrating to go mod.
Two things need to be fixed to get our build process working after migrating to go mod:
tools.go
file to import it but exclude it in build (with a build tag+build tools
) and then rerungo mod tidy
andgo mod vendor
. Usingtools.go
is the recommended way of managing tool dependency version with go mod cmd/go: clarify best practice for tool dependencies golang/go#25922 (comment).version-gen.go
. otherwise the build script can fail in container due to no network access (also added the explanation as comments)Testing
Rely on existing tests.
Description for the changelog
N/A (not changing any agent functionality)
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.