ci.chef.wlp
ci.chef.wlp copied to clipboard
Defaulting String properties to `nil` in LWRPs breaks in chef13
When running the test suites using Chef13, I get the following error:
Compiling Cookbooks...
================================================================================
Recipe Compile Error in /tmp/kitchen/cache/cookbooks/wlp/resources/download_feature.rb
================================================================================
Chef::Exceptions::ValidationFailed
----------------------------------
Property name must be one of: String! You passed nil.
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/wlp/resources/download_feature.rb:39:in `class_from_file'
Relevant File Content:
----------------------
/tmp/kitchen/cache/cookbooks/wlp/resources/download_feature.rb:
32: #>
33: =end
34:
35: actions :download
36:
37:
38: #<> @attribute name Specifies the name of the asset to be downloaded.
39>> attribute :name, :kind_of => String, :default => nil
40:
41: #<> @attribute directory Specifies which local directory path utilities are downloaded to when using the :download action.
42: attribute :directory, :kind_of => String, :default => nil
43:
44: #<> @attribute accept_license Specifies whether to accept the license terms and conditions of the feature.
45: attribute :accept_license, :kind_of => [TrueClass, FalseClass], :default => false
46:
47: default_action :download
48:
System Info:
------------
chef_version=13.8.5
platform=ubuntu
platform_version=14.04
ruby=ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
program_name=chef-solo worker: ppid=1540;start=05:09:16;
executable=/opt/chef/bin/chef-solo
This is because the type of the property is limited to String
which is strongly enforced by Chef. Either the default needs to be removed, or the :kind_of
needs to be expanded to support [String, NilClass]
. Looking at the usage, removing the default seems to be appropriate in this case. This error impacts:
-
install_feature
resource -name
property -
download_feature
resource -name
anddirectory
properties.
I have a fix in place and will be happy to submit the PR, but my branch is based off of PR #50. So if that gets merged it'll be easy to roll this fix in too.