From 29d5675b4db5ede24214227b1bcb2c85e50fc8e6 Mon Sep 17 00:00:00 2001 From: Kirill Trofimov Date: Wed, 24 Jan 2024 11:01:49 +0100 Subject: [PATCH] Add Podman Desktop --- Evergreen/Apps/Get-PodmanDesktop.ps1 | 34 +++++++++++++++++++++++ Evergreen/Manifests/PodmanDesktop.json | 20 +++++++++++++ Evergreen/Private/Get-InstallerType.ps1 | 1 + tests/Private/Get-InstallerType.Tests.ps1 | 8 ++++++ 4 files changed, 63 insertions(+) create mode 100644 Evergreen/Apps/Get-PodmanDesktop.ps1 create mode 100644 Evergreen/Manifests/PodmanDesktop.json diff --git a/Evergreen/Apps/Get-PodmanDesktop.ps1 b/Evergreen/Apps/Get-PodmanDesktop.ps1 new file mode 100644 index 00000000..a21ff757 --- /dev/null +++ b/Evergreen/Apps/Get-PodmanDesktop.ps1 @@ -0,0 +1,34 @@ +Function Get-PodmanDesktop { + <# + .SYNOPSIS + Returns the available Podman Desktop versions. + + .NOTES + Author: Kirill Trofimov + #> + [OutputType([System.Management.Automation.PSObject])] + [CmdletBinding(SupportsShouldProcess = $False)] + param ( + [Parameter(Mandatory = $False, Position = 0)] + [ValidateNotNull()] + [System.Management.Automation.PSObject] + $res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1]) + ) + + # Pass the repo releases API URL and return a formatted object + $params = @{ + Uri = $res.Get.Uri + MatchVersion = $res.Get.MatchVersion + Filter = $res.Get.MatchFileTypes + } + $object = Get-GitHubRepoRelease @params + + # For windows there are two different .exe versions. + foreach ($o in $object) { + if (-not($o.URI.contains("setup")) -and $o.URI.EndsWith(".exe")) { + $o.InstallerType = "Portable" + } + } + + Write-Output -InputObject $object +} diff --git a/Evergreen/Manifests/PodmanDesktop.json b/Evergreen/Manifests/PodmanDesktop.json new file mode 100644 index 00000000..b7ea822f --- /dev/null +++ b/Evergreen/Manifests/PodmanDesktop.json @@ -0,0 +1,20 @@ +{ + "Name": "Podman Desktop", + "Source": "https://github.com/containers/podman-desktop", + "Get": { + "Uri": "https://api.github.com/repos/containers/podman-desktop/releases/latest", + "MatchVersion": "(\\d+(\\.\\d+){1,4}).*", + "MatchFileTypes": "\\.exe$" + }, + "Install": { + "Setup": "podman-desktop*.exe", + "Physical": { + "Arguments": "/S", + "PostInstall": [] + }, + "Virtual": { + "Arguments": "", + "PostInstall": [] + } + } +} diff --git a/Evergreen/Private/Get-InstallerType.ps1 b/Evergreen/Private/Get-InstallerType.ps1 index 33b3cd8f..dd3304c2 100644 --- a/Evergreen/Private/Get-InstallerType.ps1 +++ b/Evergreen/Private/Get-InstallerType.ps1 @@ -12,6 +12,7 @@ function Get-InstallerType { "portable" { $Type = "Portable"; break } "no-installer" { $Type = "Portable"; break } "debug" { $Type = "Debug"; break } + "airgap" { $Type = "Airgap"; break } default { Write-Verbose -Message "$($MyInvocation.MyCommand): Installer type not found in $String, defaulting to 'Default'." $Type = "Default" diff --git a/tests/Private/Get-InstallerType.Tests.ps1 b/tests/Private/Get-InstallerType.Tests.ps1 index 6fa302b6..65b51fb5 100644 --- a/tests/Private/Get-InstallerType.Tests.ps1 +++ b/tests/Private/Get-InstallerType.Tests.ps1 @@ -41,5 +41,13 @@ Describe -Name "Get-InstallerType" { Get-InstallerType -String $Url | Should -Be "Debug" } } + + It "Returns Airgap given an airgap URL" { + InModuleScope -ModuleName "Evergreen" { + $Url = "https://github.com/containers/podman-desktop/releases/download/v1.6.4/podman-desktop-airgap-1.6.4-x64.exe" + Get-InstallerType -String $Url | Should -Be "Airgap" + } + } + } }