Browse Source

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 6 năm trước cách đây
mục cha
commit
755d3057ab
1 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 3 3
      hack/ci/windows.ps1

+ 3 - 3
hack/ci/windows.ps1

@@ -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$',''
         }