-
Notifications
You must be signed in to change notification settings - Fork 27
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
(MAINT) Fix powershell_version OS guard #122
Merged
ThoughtCrhyme
merged 1 commit into
puppetlabs:master
from
michaeltlombardi:maint-fix-facter
Aug 21, 2019
Merged
(MAINT) Fix powershell_version OS guard #122
ThoughtCrhyme
merged 1 commit into
puppetlabs:master
from
michaeltlombardi:maint-fix-facter
Aug 21, 2019
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prior to this commit the library code for retrieving the powershell version on the box had a failing guard which gated the requiring of win32/registry behind a platform-dependent check, but not the rest of the logic which relies on that code. This commit corrects the regression.
kreeuwijk
approved these changes
Aug 21, 2019
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.
Fixes it!
Notice: Local environment: 'production' doesn't match server specified node environment 'development', switching agent to 'development'.
Info: Retrieving pluginfacts
Info: Retrieving plugin
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/powershell_version.rb]/content: content changed '{md5}dcefec62cfb871bad5590b5fe0b85494' to '{md5}79ab33006cb3c2319193024733f3cf0d'
Notice: /File[/opt/puppetlabs/puppet/cache/lib/puppet_x/puppetlabs/dsc_lite/powershell_version.rb]/content:
--- /opt/puppetlabs/puppet/cache/lib/puppet_x/puppetlabs/dsc_lite/powershell_version.rb 2019-08-21 20:29:12.228690900 +0200
+++ /tmp/puppet-file20190821-54497-fa0f3a 2019-08-21 20:51:51.416690900 +0200
@@ -13,61 +13,60 @@
if Puppet::Util::Platform.windows?
require 'win32/registry'
-end
+ module PuppetX
+ module PuppetLabs
+ module DscLite
+ # Gets the Powershell version
+ class PowerShellVersion
+ # Access rights used to access registry
+ ACCESS_TYPE = Win32::Registry::KEY_READ | 0x100
+ # Alias for HKEY_LOCAL_MACHINE registry
+ HKLM = Win32::Registry::HKEY_LOCAL_MACHINE
+ # Registry key for PS 1 engine path
+ PS_ONE_REG_PATH = 'SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine'.freeze
+ # Registry key for PS 3 engine path
+ PS_THREE_REG_PATH = 'SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine'.freeze
+ # Registry key for current PS version
+ REG_KEY = 'PowerShellVersion'.freeze
-module PuppetX
- module PuppetLabs
- module DscLite
- # Gets the Powershell version
- class PowerShellVersion
- # Access rights used to access registry
- ACCESS_TYPE = Win32::Registry::KEY_READ | 0x100
- # Alias for HKEY_LOCAL_MACHINE registry
- HKLM = Win32::Registry::HKEY_LOCAL_MACHINE
- # Registry key for PS 1 engine path
- PS_ONE_REG_PATH = 'SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine'.freeze
- # Registry key for PS 3 engine path
- PS_THREE_REG_PATH = 'SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine'.freeze
- # Registry key for current PS version
- REG_KEY = 'PowerShellVersion'.freeze
-
- # Retrieves version of current PS installation. An installation for PS 3 and PS 1 is checked
- # for, with the version of a PS 3 installation taking precedence over that of a PS 1
- # installation.
- #
- # @return [String] version
- def self.version
- powershell_three_version || powershell_one_version
- end
+ # Retrieves version of current PS installation. An installation for PS 3 and PS 1 is checked
+ # for, with the version of a PS 3 installation taking precedence over that of a PS 1
+ # installation.
+ #
+ # @return [String] version
+ def self.version
+ powershell_three_version || powershell_one_version
+ end
- # Retrieves version of PS 1 installation
- #
- # @return [String] version
- def self.powershell_one_version
- version = nil
- begin
- HKLM.open(PS_ONE_REG_PATH, ACCESS_TYPE) do |reg|
- version = reg[REG_KEY]
- end
- rescue
+ # Retrieves version of PS 1 installation
+ #
+ # @return [String] version
+ def self.powershell_one_version
version = nil
+ begin
+ HKLM.open(PS_ONE_REG_PATH, ACCESS_TYPE) do |reg|
+ version = reg[REG_KEY]
+ end
+ rescue
+ version = nil
+ end
+ version
end
- version
- end
- # Retrieves version of PS 3 installation
- #
- # @return [String] version
- def self.powershell_three_version
- version = nil
- begin
- HKLM.open(PS_THREE_REG_PATH, ACCESS_TYPE) do |reg|
- version = reg[REG_KEY]
- end
- rescue
+ # Retrieves version of PS 3 installation
+ #
+ # @return [String] version
+ def self.powershell_three_version
version = nil
+ begin
+ HKLM.open(PS_THREE_REG_PATH, ACCESS_TYPE) do |reg|
+ version = reg[REG_KEY]
+ end
+ rescue
+ version = nil
+ end
+ version
end
- version
end
end
end
Notice: /File[/opt/puppetlabs/puppet/cache/lib/puppet_x/puppetlabs/dsc_lite/powershell_version.rb]/content: content changed '{md5}ec909a9cb3b87946a7a13fcfe1a1b680' to '{md5}9bbc7ad8919dc67f11bd1af673fc2975'
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for splunk.dreamworx.nl
Info: Applying configuration version 'puppet-development-63fe40174b8'
Notice: Applied catalog in 2.23 seconds```
ThoughtCrhyme
approved these changes
Aug 21, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this commit the library code for retrieving the powershell
version on the box had a failing guard which gated the requiring of
win32/registry behind a platform-dependent check, but not the rest
of the logic which relies on that code.
This commit corrects the regression.