Browse code

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2018/12/23 05:29:26
Showing 1 changed files
... ...
@@ -429,14 +429,14 @@ Try {
429 429
     Write-Host -ForegroundColor Green "INFO: Location for testing is $env:TEMP"
430 430
 
431 431
     # CI Integrity check - ensure Dockerfile.windows and Dockerfile go versions match
432
-    $goVersionDockerfileWindows=$(Get-Content ".\Dockerfile.windows" | Select-String "^ENV GO_VERSION").ToString().Replace("ENV GO_VERSION=","").Replace("\","").Replace("``","").Trim()
433
-    $goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^ENV GO_VERSION")
432
+    $goVersionDockerfileWindows=$(Get-Content ".\Dockerfile.windows" | Select-String "^ENV GO_VERSION" | Select-object -First 1).ToString().Replace("ENV GO_VERSION=","").Replace("\","").Replace("``","").Trim()
433
+    $goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^ENV GO_VERSION" | Select-object -First 1)
434 434
     
435 435
     # As of go 1.11, Dockerfile changed to be in the format like "FROM golang:1.11.0 AS base".
436 436
     # If a version number ends with .0 (as in 1.11.0, a convention used in golang docker
437 437
     # image versions), it needs to be removed (i.e. "1.11.0" becomes "1.11").
438 438
     if ($null -eq $goVersionDockerfile) {
439
-        $goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^FROM golang:")
439
+        $goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^FROM golang:" | Select-object -First 1)
440 440
         if ($null -ne $goVersionDockerfile) {
441 441
             $goVersionDockerfile = $goVersionDockerfile.ToString().Split(" ")[1].Split(":")[1] -replace '\.0$',''
442 442
         }