Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 59 additions & 17 deletions Apps/Get-DockerDesktop.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,65 @@ function Get-DockerDesktop {
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
)

# Get the releases data
$Updates = Invoke-EvergreenRestMethod -Uri $res.Get.Update.Uri

# Select the latest version
$Latest = $Updates | `
Sort-Object -Property @{ Expression = { [System.Version]$_.enclosure.shortVersionString }; Descending = $true } | `
Select-Object -First 1

# Output the latest version
foreach ($Item in $Latest.enclosure.url) {
$PSObject = [PSCustomObject] @{
Version = $Latest.enclosure.shortVersionString
Build = $Latest.enclosure.version
Size = $Latest.enclosure.length
Type = Get-FileType -File $Item
URI = $Item
foreach ($Url in $res.Get.Update.Uri) {
# Get the releases data
$Updates = Invoke-EvergreenRestMethod -Uri $Url

# Keep only entries that can be version-sorted
$ValidUpdates = $Updates | Where-Object {
($null -ne $_.enclosure) -and
($null -ne $_.enclosure.shortVersionString)
}
if ($ValidUpdates.Count -eq 0) {
throw "$($MyInvocation.MyCommand): No valid release entries found with enclosure.shortVersionString."
}

# Select the latest version
$Latest = $ValidUpdates | `
Sort-Object -Property @{ Expression = { [System.Version]$_.enclosure.shortVersionString }; Descending = $true } | `
Select-Object -First 1

if (($null -eq $Latest) -or ($null -eq $Latest.enclosure)) {
throw "$($MyInvocation.MyCommand): Latest release entry is missing enclosure data."
}

$RequiredEnclosureProperties = @(
"shortVersionString",
"version",
"length",
"url"
)

foreach ($Property in $RequiredEnclosureProperties) {
if (-not ($Latest.enclosure.PSObject.Properties.Name -contains $Property)) {
throw "$($MyInvocation.MyCommand): Latest release entry is missing required enclosure property '$Property'."
}

if ($null -eq $Latest.enclosure.$Property) {
throw "$($MyInvocation.MyCommand): Latest release enclosure property '$Property' is null."
}
}

$Urls = @($Latest.enclosure.url) | Where-Object {
-not [System.String]::IsNullOrWhiteSpace([System.String]$_)
}
if ($Urls.Count -eq 0) {
throw "$($MyInvocation.MyCommand): Latest release enclosure property 'url' has no valid values."
}
Write-Verbose -Message "$($MyInvocation.MyCommand): Found version: $($Latest.enclosure.shortVersionString)."

# Output the latest version
foreach ($Item in $Urls) {
$PSObject = [PSCustomObject] @{
Version = $Latest.enclosure.shortVersionString
Build = $Latest.enclosure.version
Size = $Latest.enclosure.length
Architecture = Get-Architecture -String $Item
Type = Get-FileType -File $Item
FileName = [System.IO.Path]::GetFileName($Item)
URI = $Item -replace " ", "%20"
}
Write-Output -InputObject $PSObject
}
Write-Output -InputObject $PSObject
}
}
5 changes: 4 additions & 1 deletion Manifests/DockerDesktop.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"Source": "https://www.docker.com/products/docker-desktop/",
"Get": {
"Update": {
"Uri": "https://desktop.docker.com/win/main/amd64/appcast.xml"
"Uri": [
"https://desktop.docker.com/win/main/amd64/appcast.xml",
"https://desktop.docker.com/win/main/arm64/appcast.xml"
]
}
},
"Install": {
Expand Down
Loading