From 9854388b73b97f50ac14d5583beaf737313ade26 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 9 Nov 2018 19:03:18 -0800 Subject: windows_feature: Move provider logic into the default of the install_method property This eliminates the need for setting the subresource variable and also allows us to auto-generate docs that are aware of the default. Signed-off-by: Tim Smith --- lib/chef/resource/windows_feature.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/chef/resource/windows_feature.rb') 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 -- cgit v1.2.1