diff options
author | John Keiser <john@johnkeiser.com> | 2015-12-18 14:48:45 -0800 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2016-01-27 10:23:20 -0800 |
commit | 7520f3d36d2c8029c6c2996dd9289e9f74b9e6d3 (patch) | |
tree | 8e9aa1e623d3c92794dfc502be7350e8aa760e92 /lib/chef/resource | |
parent | c3f1021fc6107808826461279cfd6eb055aa6162 (diff) | |
download | chef-7520f3d36d2c8029c6c2996dd9289e9f74b9e6d3.tar.gz |
Fix nil with properties:
1. Warn when default values are invalid.
2. Never validate nil (on set or get) if there is no default.
3. Emit "will be invalid in Chef 13" warning when setting an invalid nil value.
Diffstat (limited to 'lib/chef/resource')
-rw-r--r-- | lib/chef/resource/chef_gem.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource/file.rb | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb index 233ae66026..655534684c 100644 --- a/lib/chef/resource/chef_gem.rb +++ b/lib/chef/resource/chef_gem.rb @@ -26,9 +26,9 @@ class Chef property :gem_binary, default: "#{RbConfig::CONFIG['bindir']}/gem", callbacks: { - "The chef_gem resource is restricted to the current gem environment, use gem_package to install to other environments." => proc { false } + "The chef_gem resource is restricted to the current gem environment, use gem_package to install to other environments." => proc { |v| v == properties[:gem_binary].default } } - property :compile_time, [ true, false ], default: lazy { Chef::Config[:chef_gem_compile_time] }, desired_state: false + property :compile_time, [ true, false, nil ], default: lazy { Chef::Config[:chef_gem_compile_time] }, desired_state: false def after_created # Chef::Resource.run_action: Caveat: this skips Chef::Runner.run_action, where notifications are handled diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb index 0a530e27c9..52cb409226 100644 --- a/lib/chef/resource/file.rb +++ b/lib/chef/resource/file.rb @@ -49,7 +49,7 @@ class Chef allowed_actions :create, :delete, :touch, :create_if_missing property :path, String, name_property: true, identity: true - property :atomic_update, [ true, false ], desired_state: false, default: Chef::Config[:file_atomic_update] + property :atomic_update, [ true, false ], desired_state: false, default: lazy { Chef::Config[:file_atomic_update] } property :backup, [ Integer, false ], desired_state: false, default: 5 property :checksum, [ /^[a-zA-Z0-9]{64}$/, nil ] property :content, [ String, nil ], desired_state: false |