summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-02-28 16:06:46 -0800
committerTim Smith <tsmith84@gmail.com>2020-02-28 16:06:46 -0800
commite9bc7871e519285cd1f5a82837cc5d2ff6c7af8b (patch)
tree863de03f238762e9e5676824f6b1aa85d799d407
parent7fa565737fb3cc984ad686266bbe3fec30312510 (diff)
downloadchef-older_than_win_2012_or_8.tar.gz
Deprecate the older_than_win_2012_or_8? helperolder_than_win_2012_or_8
Within Chef this is only used in the windows_feature_powershell resource which I've cleaned up. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/dsl/platform_introspection.rb3
-rw-r--r--lib/chef/resource/windows_feature_powershell.rb11
2 files changed, 5 insertions, 9 deletions
diff --git a/lib/chef/dsl/platform_introspection.rb b/lib/chef/dsl/platform_introspection.rb
index 8cb625d9c9..9ce3aa3513 100644
--- a/lib/chef/dsl/platform_introspection.rb
+++ b/lib/chef/dsl/platform_introspection.rb
@@ -248,6 +248,8 @@ class Chef
end
# a simple helper to determine if we're on a windows release pre-2012 / 8
+ #
+ # @deprecated Windows releases before Windows 2012 and 8 are no longer supported
# @return [Boolean] Is the system older than Windows 8 / 2012
def older_than_win_2012_or_8?(node = run_context.nil? ? nil : run_context.node)
node["platform_version"].to_f < 6.2
@@ -256,7 +258,6 @@ class Chef
# ^^^^^^ NOTE: PLEASE DO NOT CONTINUE TO ADD THESE KINDS OF PLATFORM_VERSION APIS WITHOUT ^^^^^^^
# ^^^^^^ GOING THROUGH THE DESIGN REVIEW PROCESS AND ADDRESS THE EXISTING CHEF-SUGAR ONES ^^^^^^^
# ^^^^^^ DO "THE HARD RIGHT THING" AND ADDRESS THE BROADER PROBLEM AND FIX IT ALL. ^^^^^^^
-
end
end
end
diff --git a/lib/chef/resource/windows_feature_powershell.rb b/lib/chef/resource/windows_feature_powershell.rb
index 8f9abb002b..e848df0ec1 100644
--- a/lib/chef/resource/windows_feature_powershell.rb
+++ b/lib/chef/resource/windows_feature_powershell.rb
@@ -190,13 +190,8 @@ class Chef
# fetch the list of available feature names and state in JSON and parse the JSON
def parsed_feature_list
- # Grab raw feature information from dism command line
- # Windows < 2012 doesn't present a state value so we have to check if the feature is installed or not
- raw_list_of_features = if older_than_win_2012_or_8? # make the older format look like the new format, warts and all
- powershell_out!('Get-WindowsFeature | Select-Object -Property Name, @{Name="InstallState"; Expression = {If ($_.Installed) { 1 } Else { 0 }}} | ConvertTo-Json -Compress', timeout: new_resource.timeout).stdout
- else
- powershell_out!("Get-WindowsFeature | Select-Object -Property Name,InstallState | ConvertTo-Json -Compress", timeout: new_resource.timeout).stdout
- end
+ # Grab raw feature information from WindowsFeature
+ raw_list_of_features = powershell_out!("Get-WindowsFeature | Select-Object -Property Name,InstallState | ConvertTo-Json -Compress", timeout: new_resource.timeout).stdout
Chef::JSONCompat.from_json(raw_list_of_features)
end
@@ -205,7 +200,7 @@ class Chef
# @return [void]
def add_to_feature_mash(feature_type, feature_details)
# add the lowercase feature name to the mash unless we're on < 2012 where they're case sensitive
- node.override["powershell_features_cache"][feature_type] << (older_than_win_2012_or_8? ? feature_details : feature_details.downcase)
+ node.override["powershell_features_cache"][feature_type] << feature_details.downcase
end
# Fail if any of the packages are in a removed state