From 520f42e4b0078f11b2743bc2d44ee622e3909e84 Mon Sep 17 00:00:00 2001 From: John Howard Date: Wed, 1 Feb 2017 10:31:27 -0800 Subject: [PATCH] Windows: make.ps1 validate go version Signed-off-by: John Howard Upstream-commit: 5e7a9e523ff057f856d8a1ceb9feb7cabac6218e Component: engine --- components/engine/hack/make.ps1 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/components/engine/hack/make.ps1 b/components/engine/hack/make.ps1 index 224fbf18ce..f88f03fcac 100644 --- a/components/engine/hack/make.ps1 +++ b/components/engine/hack/make.ps1 @@ -126,6 +126,25 @@ Function Check-InContainer() { Write-Host "" Write-Warning "Not running in a container. The result might be an incorrect build." Write-Host "" + return $False + } + return $True +} + +# Utility function to warn if the version of go is correct. Used for local builds +# outside of a container where it may be out of date with master. +Function Verify-GoVersion() { + Try { + $goVersionDockerfile=(Get-Content ".\Dockerfile" | Select-String "ENV GO_VERSION").ToString().Split(" ")[2] + $goVersionInstalled=(go version).ToString().Split(" ")[2].SubString(2) + } + Catch [Exception] { + Throw "Failed to validate go version correctness: $_" + } + if (-not($goVersionInstalled -eq $goVersionDockerfile)) { + Write-Host "" + Write-Warning "Building with golang version $goVersionInstalled. You should update to $goVersionDockerfile" + Write-Host "" } } @@ -337,7 +356,10 @@ Try { # Give a warning if we are not running in a container and are building binaries or running unit tests. # Not relevant for validation tests as these are fine to run outside of a container. - if ($Client -or $Daemon -or $TestUnit) { Check-InContainer } + if ($Client -or $Daemon -or $TestUnit) { $inContainer=Check-InContainer } + + # If we are not in a container, validate the version of GO that is installed. + if (-not $inContainer) { Verify-GoVersion } # Verify GOPATH is set if ($env:GOPATH.Length -eq 0) { Throw "Missing GOPATH environment variable. See https://golang.org/doc/code.html#GOPATH" }