-
Notifications
You must be signed in to change notification settings - Fork 193
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
(MODULES-7580) Fix PowerShell task for puppet version on 32bit #309
Conversation
c6708e4
to
65cf3f5
Compare
Tested manually on Windows 10 32bit, 64bit and 2008R2 64bit. |
CLA signed by all contributors. |
tasks/version_powershell.ps1
Outdated
if ($loc -ne $null) { | ||
Write-Output "{`"version`":`"$(type $loc)`",`"source`":`"$($loc.replace('\', '/'))`"}" | ||
if ($null -ne $loc) { | ||
Write-Output "{`"version`":`"$(Get-Content -Path $loc -ErrorAction SilentlyContinue)`",`"source`":`"$($loc.replace('\', '/'))`"}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-ErrorAction SilentlyContinue
will result in an empty version if reading the file fails for some reason (permissions?). I'm not sure that's what we want... if the file is present but we can't read it, we may want to fail the task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. Can just read it first before write-Output
|
||
$reg = Get-ItemProperty -Path $rootPath -ErrorAction SilentlyContinue | ||
if ($null -ne $reg) { | ||
if ($null -ne $reg.RememberedInstallDir64) { |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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) ) {
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
65cf3f5
to
1504c52
Compare
CLA signed by all contributors. |
Ready for a rebase. |
1504c52
to
693f85a
Compare
Previously the powershell based version task was failing on 32bit windows operating systems due to passing in a null path to Test-Path. This commit modifies the detection to be far more tolerant of errors and instead detects if the registry entries are null instead of using Test-Path. This commit also cleans up the code as per PS Script Analyzer rules; * Remove use of aliases * Prefer `$null -eq ...` instead of `... -eq $null`
693f85a
to
984dadd
Compare
Previously the powershell based version task was failing on 32bit windows
operating systems due to passing in a null path to Test-Path. This commit
modifies the detection to be far more tolerant of errors and instead detects if
the registry entries are null instead of using Test-Path.
This commit also cleans up the code as per PS Script Analyzer rules;
$null -eq ...
instead of... -eq $null