From 5c4a395c525f7883b385a0f22fb30321df287fd6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 28 Jan 2022 11:35:36 +0100 Subject: [PATCH 1/2] scripts/vendor: run go mod tidy when vendoring There was some debate about this, and wether or not tidy should be run when vendoring, but without this, validation failed after running `make vendor`, and manually doing a `go mod tidy` is complicated (due to the `vendor.mod`, and because the cache is not inside the build-cache, not on the host). Signed-off-by: Sebastiaan van Stijn --- scripts/vendor | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/vendor b/scripts/vendor index 00f79c0b3a..83f51f628c 100755 --- a/scripts/vendor +++ b/scripts/vendor @@ -21,11 +21,10 @@ go 1.16 EOL update() { - (set -x ; go mod vendor -modfile=vendor.mod) + (set -x ; go mod tidy -modfile=vendor.mod; go mod vendor -modfile=vendor.mod) } validate() { - (set -x ; go mod tidy -modfile=vendor.mod) diff=$(git status --porcelain -- vendor.mod vendor.sum vendor) if [ -n "$diff" ]; then echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make -f docker.Makefile vendor"' From 0d5b24b019fcbd6ec5997aa3cf9e11bec4a2ddd0 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 28 Jan 2022 11:40:33 +0100 Subject: [PATCH 2/2] Dockerfile.vendor: use GOPROXY=direct While the module proxy can speed up vendoring, it may cause issues when (temporarily) vendoring from a fork, because the proxy may not have the module yet on first try, which causes vendoring to fail: vendor.mod:95:2: replace github.com/thaJeztah/compose-on-kubernetes: version "0b59cf047b3b0199048fe13fdcd21b0cb46549f2" invalid: Get "https://proxy.golang.org/github.com/tha%21jeztah/compose-on-kubernetes/@v/0b59cf047b3b0199048fe13fdcd21b0cb46549f2.info": read tcp 172.17.0.2:60290->172.217.168.209:443: read: connection reset by peer Using `GOPROXY=direct` to fetch sources directly from upstream (GitHub) instead. Signed-off-by: Sebastiaan van Stijn --- dockerfiles/Dockerfile.vendor | 1 + 1 file changed, 1 insertion(+) diff --git a/dockerfiles/Dockerfile.vendor b/dockerfiles/Dockerfile.vendor index 237cb5100c..6d687c6378 100644 --- a/dockerfiles/Dockerfile.vendor +++ b/dockerfiles/Dockerfile.vendor @@ -8,6 +8,7 @@ RUN apk add --no-cache bash git rsync WORKDIR /src FROM base AS vendored +ENV GOPROXY=direct RUN --mount=target=/context \ --mount=target=.,type=tmpfs \ --mount=target=/go/pkg/mod,type=cache <