Skip to content

Commit

Permalink
Fix Windows testing checking for legacy versions of the collector
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanotti committed Jan 17, 2024
1 parent 8287246 commit 7b076c6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/scripts/win-test-services.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ $ErrorActionPreference = 'Stop'
Set-PSDebug -Trace 1

function check_collector_svc_environment([hashtable]$expected_env_vars) {
$env_array = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment"
$actual_env_vars = @{}
foreach ($entry in $env_array) {
$key, $value = $entry.Split("=", 2)
$actual_env_vars.Add($key, $value)
try {
$env_array = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment"
foreach ($entry in $env_array) {
$key, $value = $entry.Split("=", 2)
$actual_env_vars.Add($key, $value)
}
} catch {
Write-Host "Assuming an old version of the collector with environment variables at the machine scope"
$actual_env_vars = [Environment]::GetEnvironmentVariables("Machine")<#Do this if a terminating exception happens#>
}

foreach ($key in $expected_env_vars.Keys) {
Expand Down

0 comments on commit 7b076c6

Please sign in to comment.