summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-03-02 15:52:50 -0800
committerTim Smith <tsmith@chef.io>2018-03-02 15:53:55 -0800
commit4f7a2764af2931683ffabef9c8d9b30bfb5dc891 (patch)
treec1aa6907daf3c01615fdad0db3e62b956c8c1977
parent2a098b7a4fc94d42050c6c0bc92cb08fb78a6817 (diff)
downloadchef-4f7a2764af2931683ffabef9c8d9b30bfb5dc891.tar.gz
Simplify how we select the subresource
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/windows_feature.rb39
1 files changed, 10 insertions, 29 deletions
diff --git a/lib/chef/resource/windows_feature.rb b/lib/chef/resource/windows_feature.rb
index 101140e940..bb6aa94dcd 100644
--- a/lib/chef/resource/windows_feature.rb
+++ b/lib/chef/resource/windows_feature.rb
@@ -69,38 +69,19 @@ class Chef
end
action_class do
- # @return [Symbol] :windows_feature_dism or the subresource specified in install_method property
- def locate_default_subresource
- if new_resource.install_method
- new_resource.install_method
- else
- :windows_feature_dism
- end
- end
-
# call the appropriate windows_feature resource based on the specified subresource
# @return [void]
def run_default_subresource(desired_action)
- case locate_default_subresource
- when :windows_feature_dism
- windows_feature_dism 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
- end
- when :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 cookbook to install either via dism or powershell (preferred)."
- when :windows_feature_powershell
- windows_feature_powershell 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
- end
+ 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
+
+ subresource = new_resource.install_method || :windows_feature_dism
+ declare_resource(subresource, 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
end
end
end