PowerShell: Go-version check; only select the first match

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2018-12-22 21:29:26 +01:00
parent 6130c89cce
commit 755d3057ab
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 3 additions and 3 deletions

View File

@ -429,14 +429,14 @@ Try {
Write-Host -ForegroundColor Green "INFO: Location for testing is $env:TEMP"
# CI Integrity check - ensure Dockerfile.windows and Dockerfile go versions match
$goVersionDockerfileWindows=$(Get-Content ".\Dockerfile.windows" | Select-String "^ENV GO_VERSION").ToString().Replace("ENV GO_VERSION=","").Replace("\","").Replace("``","").Trim()
$goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^ENV GO_VERSION")
$goVersionDockerfileWindows=$(Get-Content ".\Dockerfile.windows" | Select-String "^ENV GO_VERSION" | Select-object -First 1).ToString().Replace("ENV GO_VERSION=","").Replace("\","").Replace("``","").Trim()
$goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^ENV GO_VERSION" | Select-object -First 1)
# As of go 1.11, Dockerfile changed to be in the format like "FROM golang:1.11.0 AS base".
# If a version number ends with .0 (as in 1.11.0, a convention used in golang docker
# image versions), it needs to be removed (i.e. "1.11.0" becomes "1.11").
if ($null -eq $goVersionDockerfile) {
$goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^FROM golang:")
$goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^FROM golang:" | Select-object -First 1)
if ($null -ne $goVersionDockerfile) {
$goVersionDockerfile = $goVersionDockerfile.ToString().Split(" ")[1].Split(":")[1] -replace '\.0$',''
}