Skip to content

Commit

Permalink
Update 1Password #588
Browse files Browse the repository at this point in the history
Update with MSI download. Picks a single CDN source so that the URI value for the exe download does not change on each run
  • Loading branch information
aaronparker committed Mar 26, 2024
1 parent ae0524a commit d2fc18f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
37 changes: 23 additions & 14 deletions Evergreen/Apps/Get-1Password.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Function Get-1Password {
function Get-1Password {
<#
.SYNOPSIS
Get the current version and download URL for 1Password 8 and later.
Expand All @@ -11,7 +11,7 @@ Function Get-1Password {
[OutputType([System.Management.Automation.PSObject])]
[CmdletBinding(SupportsShouldProcess = $False)]
param (
[Parameter(Mandatory = $False, Position = 0)]
[Parameter(Mandatory = $false, Position = 0)]
[ValidateNotNull()]
[System.Management.Automation.PSObject]
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
Expand All @@ -23,23 +23,32 @@ Function Get-1Password {
ContentType = $res.Get.Update.ContentType
}
$updateFeed = Invoke-EvergreenRestMethod @params
if ($Null -ne $updateFeed) {
if ($updateFeed.available -eq 1) {
if ($updateFeed.available -eq 1) {

# Output the object to the pipeline
foreach ($item in $updateFeed) {
$PSObject = [PSCustomObject] @{
Version = $item.version
URI = $($item.sources | Select-Object -Index (Get-Random -Minimum 0 -Maximum 2)).url
}
Write-Output -InputObject $PSObject
# Output the object to the pipeline from the update feed
foreach ($item in $updateFeed) {

# Pick a URL from the list of returns URLs
# $Url = $($item.sources | Select-Object -Index (Get-Random -Minimum 0 -Maximum 2)).url
$Url = $item.sources | Where-Object { $_.name -eq $res.Get.Update.CDN } | Select-Object -ExpandProperty "url"

$PSObject = [PSCustomObject] @{
Version = $item.version
Type = Get-FileType -File $Url
URI = $Url
}
Write-Output -InputObject $PSObject
}
else {
Write-Warning -Message "$($MyInvocation.MyCommand): failed to find an available from: $($res.Get.Update.Uri)."

# Output the MSI version of the 1Password installer
$PSObject = [PSCustomObject] @{
Version = $item.version
Type = Get-FileType -File $res.Get.Download.Uri
URI = $res.Get.Download.Uri
}
Write-Output -InputObject $PSObject
}
else {
Write-Error -Message "$($MyInvocation.MyCommand): unable to retrieve content from $($res.Get.Update.Uri)."
Write-Warning -Message "$($MyInvocation.MyCommand): failed to find an available from: $($res.Get.Update.Uri)."
}
}
1 change: 1 addition & 0 deletions Evergreen/Apps/Get-1PasswordCLI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function Get-1PasswordCLI {
$PSObject = [PSCustomObject] @{
Version = $updateFeed.version
Architecture = $Architecture.Name
Type = Get-FileType -File $res.Get.Download.Uri[$Architecture.Name]
URI = $res.Get.Download.Uri[$Architecture.Name] -replace $res.Get.Download.ReplaceText, $updateFeed.version
}
Write-Output -InputObject $PSObject
Expand Down
6 changes: 5 additions & 1 deletion Evergreen/Manifests/1Password.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"Get": {
"Update": {
"Uri": "https://app-updates.agilebits.com/check/2/10.0.2009/x86_64/OPW8/en/80600098/A1/N",
"ContentType": "application/json; charset=utf-8"
"ContentType": "application/json; charset=utf-8",
"CDN": "AgileBits"
},
"Download": {
"Uri": "https://downloads.1password.com/win/1PasswordSetup-latest.msi"
}
},
"Install": {
Expand Down

0 comments on commit d2fc18f

Please sign in to comment.