summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-03-18 08:57:03 -0700
committerGitHub <noreply@github.com>2020-03-18 08:57:03 -0700
commit2053ef67f1fd26551edde4eb5a9101893b617e12 (patch)
treeb086d78c85d4eb5ba174d3b8b727cdd1398067b2
parente0e731d8cb30cecadf809b1ab1bae58793aacc8e (diff)
parent7b657b8aed794bee21c99bf532588109b7cea070 (diff)
downloadchef-2053ef67f1fd26551edde4eb5a9101893b617e12.tar.gz
Merge pull request #9492 from MsysTechnologiesllc/sangmesh/Fixed_Use_Ohai_data_to_determine_if_we_have_PowerShell_installed
powershell_package: Use ohai data to get the powershell release instead of shelling out
-rw-r--r--lib/chef/provider/package/powershell.rb2
-rw-r--r--spec/unit/provider/package/powershell_spec.rb3
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/chef/provider/package/powershell.rb b/lib/chef/provider/package/powershell.rb
index a27f7fa6c8..01fe603363 100644
--- a/lib/chef/provider/package/powershell.rb
+++ b/lib/chef/provider/package/powershell.rb
@@ -36,7 +36,7 @@ class Chef
def define_resource_requirements
super
- if powershell_out("$PSVersionTable.PSVersion.Major").stdout.strip.to_i < 5
+ if powershell_version < 5
raise "Minimum installed PowerShell Version required is 5"
end
diff --git a/spec/unit/provider/package/powershell_spec.rb b/spec/unit/provider/package/powershell_spec.rb
index e4adc402cb..455ec21092 100644
--- a/spec/unit/provider/package/powershell_spec.rb
+++ b/spec/unit/provider/package/powershell_spec.rb
@@ -19,7 +19,7 @@
require "spec_helper"
require "chef/mixin/powershell_out"
-describe Chef::Provider::Package::Powershell do
+describe Chef::Provider::Package::Powershell, :windows_only do
include Chef::Mixin::PowershellOut
let(:timeout) { 900 }
let(:source) { nil }
@@ -28,6 +28,7 @@ describe Chef::Provider::Package::Powershell do
let(:provider) do
node = Chef::Node.new
+ node.consume_external_attrs(OHAI_SYSTEM.data.dup, {})
events = Chef::EventDispatch::Dispatcher.new
run_context = Chef::RunContext.new(node, {}, events)
Chef::Provider::Package::Powershell.new(new_resource, run_context)