summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-11-12 09:15:29 -0800
committerGitHub <noreply@github.com>2018-11-12 09:15:29 -0800
commit9cb7e953f8e04d46fced6da87cba414c591c904c (patch)
tree0aadd52812ad24454c0d3179fc6bc32a70f2ffd8
parenta97e5da2e9dc3218da8df80eb905013effc85ca9 (diff)
parent9854388b73b97f50ac14d5583beaf737313ade26 (diff)
downloadchef-9cb7e953f8e04d46fced6da87cba414c591c904c.tar.gz
Merge pull request #7912 from chef/windows_feature
windows_feature: Move provider logic into the default of the install_method property
-rw-r--r--lib/chef/resource/windows_feature.rb10
-rw-r--r--spec/unit/resource/windows_feature.rb4
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/chef/resource/windows_feature.rb b/lib/chef/resource/windows_feature.rb
index 1ae13a9a2f..d705de857f 100644
--- a/lib/chef/resource/windows_feature.rb
+++ b/lib/chef/resource/windows_feature.rb
@@ -44,7 +44,8 @@ class Chef
property :install_method, Symbol,
description: "The underlying installation method to use for feature installation. Specify ':windows_feature_dism' for DISM or ':windows_feature_powershell' for PowerShell.",
- equal_to: [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd]
+ equal_to: [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd],
+ default: :windows_feature_dism
property :timeout, Integer,
description: "Specifies a timeout (in seconds) for the feature installation.",
@@ -72,16 +73,15 @@ class Chef
# call the appropriate windows_feature resource based on the specified subresource
# @return [void]
def run_default_subresource(desired_action)
- raise "Support for Windows feature installation via servermanagercmd.exe has been removed as this support is no longer needed in Windows 2008 R2 and above. You will need to update your cookbook to install either via dism or powershell (preferred)." if new_resource.install_method == :windows_feature_servermanagercmd
+ raise "Support for Windows feature installation via servermanagercmd.exe has been removed as this support is no longer needed in Windows 2008 R2 and above. You will need to update your recipe to install either via dism or powershell (preferred)." if new_resource.install_method == :windows_feature_servermanagercmd
- subresource = new_resource.install_method || :windows_feature_dism
- declare_resource(subresource, new_resource.name) do
+ declare_resource(new_resource.install_method, new_resource.name) do
action desired_action
feature_name new_resource.feature_name
source new_resource.source if new_resource.source
all new_resource.all
timeout new_resource.timeout
- management_tools new_resource.management_tools if subresource == :windows_feature_powershell
+ management_tools new_resource.management_tools if new_resource.install_method == :windows_feature_powershell
end
end
end
diff --git a/spec/unit/resource/windows_feature.rb b/spec/unit/resource/windows_feature.rb
index f01bc3b864..eec895fad9 100644
--- a/spec/unit/resource/windows_feature.rb
+++ b/spec/unit/resource/windows_feature.rb
@@ -50,6 +50,10 @@ describe Chef::Resource::WindowsFeature do
expect(resource.timeout).to eql(600)
end
+ it "install_method property defaults to :windows_feature_dism" do
+ expect(resource.install_method).to eql(:windows_feature_dism)
+ end
+
it "install_method accepts :windows_feature_dism, :windows_feature_powershell, and :windows_feature_servermanagercmd" do
expect { resource.install_method :windows_feature_dism }.not_to raise_error
expect { resource.install_method :windows_feature_powershell }.not_to raise_error