Files
runner-images/images/windows/scripts/build/Install-DockerWinCred.ps1
Vasilii Polikarpov 5ed2615017 [Windows] Cleanup various scripts (#8942)
* Use Resolve-GithubReleaseAssetUrl more widely

* Add the Get-ChecksumFromUrl function

* Sort exported functions and add docs

* Remove alias and fix typo

* Fix kind checksum url and syntax

* Fix checksums url for gh cli and msys2

* [Windows] Cleanup various scripts

* Add spaces after type specifications

* Rename the Take-Part function
2023-12-04 10:50:53 +01:00

23 lines
985 B
PowerShell

################################################################################
## File: Install-Docker-WinCred.ps1
## Desc: Install Docker credential helper.
## Supply chain security: checksum validation
################################################################################
Write-Host "Install docker-wincred"
$downloadUrl = Resolve-GithubReleaseAssetUrl `
-Repo "docker/docker-credential-helpers" `
-Version "latest" `
-UrlMatchPattern "docker-credential-wincred-*amd64.exe"
$binaryPath = Invoke-DownloadWithRetry -Url $downloadUrl -Path "C:\Windows\System32\docker-credential-wincred.exe"
#region Supply chain security
$binaryName = Split-Path $downloadUrl -Leaf
$externalHash = Get-ChecksumFromUrl -Type "SHA256" `
-Url ($downloadUrl -replace $binaryName, "checksums.txt") `
-FileName $binaryName
Test-FileChecksum -Path $binaryPath -ExpectedSHA256Sum $externalHash
#endregion
Invoke-PesterTests -TestFile "Docker" -TestName "DockerWinCred"