From 441aff3a1759ec51e54ef63bd3ba415fd59c41d3 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 24 Jun 2020 17:05:58 +0200 Subject: [PATCH 1/3] fix gotestsum.installer installing wrong version When using go modules, `go build` will always fetch the latest version of the package, so ignores the version we previously `go get`'d. Instead of running `go get` and `go build` separately, this patch uses `go get` (without the `-d` option) to do it all in one step. Given that this binary is only used for testing, and only used inside the Dockerfile, we should consider inlining this step in the Dockerfile itself, but keeping that separate for now. Signed-off-by: Sebastiaan van Stijn --- hack/dockerfile/install/gotestsum.installer | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hack/dockerfile/install/gotestsum.installer b/hack/dockerfile/install/gotestsum.installer index 45b747dbf9..02345de0dd 100755 --- a/hack/dockerfile/install/gotestsum.installer +++ b/hack/dockerfile/install/gotestsum.installer @@ -5,7 +5,5 @@ install_gotestsum() ( set -e export GO111MODULE=on - go get -d "gotest.tools/gotestsum@${GOTESTSUM_COMMIT}" - go build ${GO_BUILDMODE} -o "${PREFIX}/gotestsum" 'gotest.tools/gotestsum' - + GOBIN="${PREFIX}" go get ${GO_BUILDMODE} "gotest.tools/gotestsum@${GOTESTSUM_COMMIT}" ) From 20570d91c84c75daa16a3d7899b070776d148140 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 24 Jun 2020 21:50:49 +0200 Subject: [PATCH 2/3] Dockerfile.windows: fix gotestsum.installer installing wrong version When using go modules, `go build` will always fetch the latest version of the package, so ignores the version we previously `go get`'d. Instead of running `go get` and `go build` separately, this patch uses `go get` (without the `-d` option) to do it all in one step. Signed-off-by: Sebastiaan van Stijn --- Dockerfile.windows | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Dockerfile.windows b/Dockerfile.windows index 1cf665c9f6..7aebec082c 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -262,15 +262,12 @@ RUN ` RUN ` Function Build-GoTestSum() { ` Write-Host "INFO: Building gotestsum version $Env:GOTESTSUM_COMMIT in $Env:GOPATH"; ` - $env:GO111MODULE = 'on'; ` - &go get -d "gotest.tools/gotestsum@${Env:GOTESTSUM_COMMIT}"; ` - $env:GO111MODULE = 'off'; ` - if ($LASTEXITCODE -ne 0) { ` - Throw '"Failed getting gotestsum sources..."' ` - }; ` - $env:GO111MODULE = 'on'; ` - &go build -buildmode=exe -o "${Env:GOPATH}\bin\gotestsum.exe" gotest.tools/gotestsum; ` - $env:GO111MODULE = 'off'; ` + $Env:GO111MODULE = 'on'; ` + $tmpGobin = "${Env:GOBIN_TMP}"; ` + $Env:GOBIN = """${Env:GOPATH}`\bin"""; ` + &go get -buildmode=exe "gotest.tools/gotestsum@${Env:GOTESTSUM_COMMIT}"; ` + $Env:GOBIN = "${tmpGobin}"; ` + $Env:GO111MODULE = 'off'; ` if ($LASTEXITCODE -ne 0) { ` Throw '"gotestsum build failed..."'; ` } ` From a9d22cad93da030c020b7c75be6ee9d158427cc7 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 26 Jun 2020 16:57:09 +0200 Subject: [PATCH 3/3] hack/install: build gotestsum without -buildmode=pie No need for this binary as it's only used in tests. Signed-off-by: Sebastiaan van Stijn --- hack/dockerfile/install/gotestsum.installer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/dockerfile/install/gotestsum.installer b/hack/dockerfile/install/gotestsum.installer index 02345de0dd..7bde0b1aab 100755 --- a/hack/dockerfile/install/gotestsum.installer +++ b/hack/dockerfile/install/gotestsum.installer @@ -5,5 +5,5 @@ install_gotestsum() ( set -e export GO111MODULE=on - GOBIN="${PREFIX}" go get ${GO_BUILDMODE} "gotest.tools/gotestsum@${GOTESTSUM_COMMIT}" + GOBIN="${PREFIX}" go get "gotest.tools/gotestsum@${GOTESTSUM_COMMIT}" )