diff options
author | Tim Smith <tsmith@chef.io> | 2018-03-28 11:56:34 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-03-28 12:03:23 -0700 |
commit | b77f792abb7753208b0f1c23af3a84b024a6ccf8 (patch) | |
tree | 05bedbc562e8cd536a9c975a72da31bf5b882bcd | |
parent | ee2d1c41844d5d28b17e0a749141a5ca9d3e6c8c (diff) | |
download | chef-b77f792abb7753208b0f1c23af3a84b024a6ccf8.tar.gz |
Keep case sensitivity on Windows < 2012case_insensitve_dism
Dism here does not support case insensitive feature installs. This isn't a user behavior change sine they always needed the feature to have the right case here.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/resource/windows_feature_dism.rb | 14 | ||||
-rw-r--r-- | spec/unit/resource/windows_feature_dism.rb | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/chef/resource/windows_feature_dism.rb b/lib/chef/resource/windows_feature_dism.rb index 0f81352dd3..2ba71a8186 100644 --- a/lib/chef/resource/windows_feature_dism.rb +++ b/lib/chef/resource/windows_feature_dism.rb @@ -46,7 +46,10 @@ class Chef def to_lowercase_array(x) x = x.split(/\s*,\s*/) if x.is_a?(String) # split multiple forms of a comma separated list - x.map(&:downcase) + + # dism on windows < 2012 is case sensitive so only downcase when on 2012+ + # @todo when we're really ready to remove support for Windows 2008 R2 this check can go away + node["platform_version"].to_f < 6.2 ? x : x.map(&:downcase) end action :install do @@ -192,8 +195,13 @@ class Chef # + | + n number of spaces # @return [void] def add_to_feature_mash(feature_type, feature_string) - feature_details = feature_string.strip.split(/\s+[|]\s+/) - node.override["dism_features_cache"][feature_type] << feature_details.first.downcase # lowercase so we can compare properly + feature_details = feature_string.strip.split(/\s+[|]\s+/).first + + # dism on windows 2012+ isn't case sensitive so it's best to compare + # lowercase lists so the user input doesn't need to be case sensitive + # @todo when we're ready to remove windows 2008R2 the gating here can go away + feature_details.downcase! unless node["platform_version"].to_f < 6.2 + node.override["dism_features_cache"][feature_type] << feature_details end # Fail if any of the packages are in a removed state diff --git a/spec/unit/resource/windows_feature_dism.rb b/spec/unit/resource/windows_feature_dism.rb index 53f3d73347..4f973f7e82 100644 --- a/spec/unit/resource/windows_feature_dism.rb +++ b/spec/unit/resource/windows_feature_dism.rb @@ -32,7 +32,7 @@ describe Chef::Resource::WindowsFeatureDism do expect(resource.feature_name).to eql(%w{snmp dhcp}) end - it "coerces comma separated lists of features to a lowercase arrays" do + it "coerces comma separated lists of features to a lowercase array" do resource.feature_name "SNMP, DHCP" expect(resource.feature_name).to eql(%w{snmp dhcp}) end |