Skip to content

Commit 3e19d81

Browse files
authored
Merge pull request #147 from EUCPilots/docker
Fix Docker #146
2 parents 6c0bcfa + 8d9c536 commit 3e19d81

2 files changed

Lines changed: 63 additions & 18 deletions

File tree

Apps/Get-DockerDesktop.ps1

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,65 @@ function Get-DockerDesktop {
1616
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
1717
)
1818

19-
# Get the releases data
20-
$Updates = Invoke-EvergreenRestMethod -Uri $res.Get.Update.Uri
21-
22-
# Select the latest version
23-
$Latest = $Updates | `
24-
Sort-Object -Property @{ Expression = { [System.Version]$_.enclosure.shortVersionString }; Descending = $true } | `
25-
Select-Object -First 1
26-
27-
# Output the latest version
28-
foreach ($Item in $Latest.enclosure.url) {
29-
$PSObject = [PSCustomObject] @{
30-
Version = $Latest.enclosure.shortVersionString
31-
Build = $Latest.enclosure.version
32-
Size = $Latest.enclosure.length
33-
Type = Get-FileType -File $Item
34-
URI = $Item
19+
foreach ($Url in $res.Get.Update.Uri) {
20+
# Get the releases data
21+
$Updates = Invoke-EvergreenRestMethod -Uri $Url
22+
23+
# Keep only entries that can be version-sorted
24+
$ValidUpdates = $Updates | Where-Object {
25+
($null -ne $_.enclosure) -and
26+
($null -ne $_.enclosure.shortVersionString)
27+
}
28+
if ($ValidUpdates.Count -eq 0) {
29+
throw "$($MyInvocation.MyCommand): No valid release entries found with enclosure.shortVersionString."
30+
}
31+
32+
# Select the latest version
33+
$Latest = $ValidUpdates | `
34+
Sort-Object -Property @{ Expression = { [System.Version]$_.enclosure.shortVersionString }; Descending = $true } | `
35+
Select-Object -First 1
36+
37+
if (($null -eq $Latest) -or ($null -eq $Latest.enclosure)) {
38+
throw "$($MyInvocation.MyCommand): Latest release entry is missing enclosure data."
39+
}
40+
41+
$RequiredEnclosureProperties = @(
42+
"shortVersionString",
43+
"version",
44+
"length",
45+
"url"
46+
)
47+
48+
foreach ($Property in $RequiredEnclosureProperties) {
49+
if (-not ($Latest.enclosure.PSObject.Properties.Name -contains $Property)) {
50+
throw "$($MyInvocation.MyCommand): Latest release entry is missing required enclosure property '$Property'."
51+
}
52+
53+
if ($null -eq $Latest.enclosure.$Property) {
54+
throw "$($MyInvocation.MyCommand): Latest release enclosure property '$Property' is null."
55+
}
56+
}
57+
58+
$Urls = @($Latest.enclosure.url) | Where-Object {
59+
-not [System.String]::IsNullOrWhiteSpace([System.String]$_)
60+
}
61+
if ($Urls.Count -eq 0) {
62+
throw "$($MyInvocation.MyCommand): Latest release enclosure property 'url' has no valid values."
63+
}
64+
Write-Verbose -Message "$($MyInvocation.MyCommand): Found version: $($Latest.enclosure.shortVersionString)."
65+
66+
# Output the latest version
67+
foreach ($Item in $Urls) {
68+
$PSObject = [PSCustomObject] @{
69+
Version = $Latest.enclosure.shortVersionString
70+
Build = $Latest.enclosure.version
71+
Size = $Latest.enclosure.length
72+
Architecture = Get-Architecture -String $Item
73+
Type = Get-FileType -File $Item
74+
FileName = [System.IO.Path]::GetFileName($Item)
75+
URI = $Item -replace " ", "%20"
76+
}
77+
Write-Output -InputObject $PSObject
3578
}
36-
Write-Output -InputObject $PSObject
3779
}
3880
}

Manifests/DockerDesktop.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"Source": "https://www.docker.com/products/docker-desktop/",
44
"Get": {
55
"Update": {
6-
"Uri": "https://desktop.docker.com/win/main/amd64/appcast.xml"
6+
"Uri": [
7+
"https://desktop.docker.com/win/main/amd64/appcast.xml",
8+
"https://desktop.docker.com/win/main/arm64/appcast.xml"
9+
]
710
}
811
},
912
"Install": {

0 commit comments

Comments
 (0)