Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-7580) Fix PowerShell task for puppet version on 32bit #309

Merged
merged 1 commit into from
Aug 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions tasks/version_powershell.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
if (Test-Path 'HKLM:\SOFTWARE\Puppet Labs\Puppet') {
$reg = $(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Puppet Labs\Puppet')
if (Test-Path $reg.RememberedInstallDir64) {
$rootPath = 'HKLM:\SOFTWARE\Puppet Labs\Puppet'

$reg = Get-ItemProperty -Path $rootPath -ErrorAction SilentlyContinue
if ($null -ne $reg) {
if ($null -ne $reg.RememberedInstallDir64) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we only want to set $loc if the path exists, can we also Test-Path? If the registry entry is there but the file isn't, I interpret that as the package is not installed (but registry cleanup didn't succeed for some reason).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add that in Line 12

if ( ($null -ne $loc) -and (Test-Path -Path $loc) ) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you going to follow up on these changes, or would you like me to take over the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to take over. Just busy with other tasks first.

$loc = $reg.RememberedInstallDir64+'VERSION'
} elseif (Test-Path $reg.RememberedInstallDir) {
} elseif ($null -ne $reg.RememberedInstallDir) {
$loc = $reg.RememberedInstallDir+'VERSION'
}
}

if ($loc -ne $null) {
Write-Output "{`"version`":`"$(type $loc)`",`"source`":`"$($loc.replace('\', '/'))`"}"
if ( ($null -ne $loc) -and (Test-Path -Path $loc) ) {
Write-Output "{`"version`":`"$(Get-Content -Path $loc -ErrorAction Stop)`",`"source`":`"$($loc.replace('\', '/'))`"}"
} else {
Write-Output '{"version":null,"source":null}'
}