Design Changes to Updater Script

This commit is contained in:
2025-11-07 21:26:43 -07:00
parent 9055d7089e
commit 541f690def

View File

@@ -25,7 +25,6 @@ function Write-UpdateLog {
if (-not $Message) { return } if (-not $Message) { return }
$timestamp = (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
$normalized = if ($Level) { $Level } else { 'INFO' } $normalized = if ($Level) { $Level } else { 'INFO' }
$normalized = $normalized.ToUpperInvariant() $normalized = $normalized.ToUpperInvariant()
@@ -43,7 +42,7 @@ function Write-UpdateLog {
} }
} }
$line = "[{0}] [{1}] {2}" -f $timestamp, $normalized, $Message $line = "[{0}] {1}" -f $normalized, $Message
if ($Color) { if ($Color) {
Write-Host $line -ForegroundColor $Color Write-Host $line -ForegroundColor $Color
} else { } else {
@@ -1478,6 +1477,23 @@ function Sync-AgentHashRecord {
} }
} }
function Invoke-AgentHashSyncStep {
param(
[string]$ProjectRoot,
[string]$AgentRoot,
[string]$AgentHash,
[string]$ServerBaseUrl,
[string]$AgentId,
[string]$AgentGuid,
[string]$AuthToken,
[string]$BranchName
)
Run-Step "Update Borealis Engine device record" {
Sync-AgentHashRecord -ProjectRoot $ProjectRoot -AgentRoot $AgentRoot -AgentHash $AgentHash -ServerBaseUrl $ServerBaseUrl -AgentId $AgentId -AgentGuid $AgentGuid -AuthToken $AuthToken -BranchName $BranchName
}
}
function Invoke-BorealisUpdate { function Invoke-BorealisUpdate {
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
@@ -1652,8 +1668,13 @@ function Invoke-BorealisAgentUpdate {
} }
$authToken = $authContext.AccessToken $authToken = $authContext.AccessToken
Write-UpdateLog "Querying Borealis server for current repository hash." 'STEP' $serverRepoInfo = $null
Run-Step "Fetch Borealis Engine repository hash" {
$serverRepoInfo = Get-ServerCurrentRepoHash -ServerBaseUrl $serverBaseUrl -AuthToken $authToken -AgentRoot $agentRoot $serverRepoInfo = Get-ServerCurrentRepoHash -ServerBaseUrl $serverBaseUrl -AuthToken $authToken -AgentRoot $agentRoot
if (-not $serverRepoInfo) {
throw "Unable to retrieve repository hash from Borealis Engine."
}
}
$serverHash = '' $serverHash = ''
$serverBranch = 'main' $serverBranch = 'main'
if ($serverRepoInfo) { if ($serverRepoInfo) {
@@ -1697,7 +1718,7 @@ function Invoke-BorealisAgentUpdate {
} elseif (-not $needsUpdate) { } elseif (-not $needsUpdate) {
Write-Host "Local agent files already match the server repository hash." -ForegroundColor Green Write-Host "Local agent files already match the server repository hash." -ForegroundColor Green
Write-UpdateLog "Local agent hash matches remote; ensuring server record is updated." 'SUCCESS' Write-UpdateLog "Local agent hash matches remote; ensuring server record is updated." 'SUCCESS'
Sync-AgentHashRecord -ProjectRoot $scriptDir -AgentRoot $agentRoot -AgentHash $serverHash -ServerBaseUrl $serverBaseUrl -AgentId $agentId -AgentGuid $agentGuid -AuthToken $authToken -BranchName $serverBranch Invoke-AgentHashSyncStep -ProjectRoot $scriptDir -AgentRoot $agentRoot -AgentHash $serverHash -ServerBaseUrl $serverBaseUrl -AgentId $agentId -AgentGuid $agentGuid -AuthToken $authToken -BranchName $serverBranch
Write-Host "✅ Borealis - Automation Platform Already Up-to-Date" Write-Host "✅ Borealis - Automation Platform Already Up-to-Date"
return return
} else { } else {
@@ -1782,7 +1803,7 @@ function Invoke-BorealisAgentUpdate {
if ($newHash) { if ($newHash) {
Write-UpdateLog ("Final agent hash determined: {0}" -f $newHash) 'INFO' Write-UpdateLog ("Final agent hash determined: {0}" -f $newHash) 'INFO'
Sync-AgentHashRecord -ProjectRoot $scriptDir -AgentRoot $agentRoot -AgentHash $newHash -ServerBaseUrl $serverBaseUrl -AgentId $agentId -AgentGuid $agentGuid -AuthToken $authToken -BranchName $serverBranch Invoke-AgentHashSyncStep -ProjectRoot $scriptDir -AgentRoot $agentRoot -AgentHash $newHash -ServerBaseUrl $serverBaseUrl -AgentId $agentId -AgentGuid $agentGuid -AuthToken $authToken -BranchName $serverBranch
} else { } else {
Write-Host "Unable to determine repository hash for submission; server hash not updated." -ForegroundColor DarkYellow Write-Host "Unable to determine repository hash for submission; server hash not updated." -ForegroundColor DarkYellow
Write-UpdateLog "Unable to determine final agent hash; skipping submission." 'WARN' Write-UpdateLog "Unable to determine final agent hash; skipping submission." 'WARN'