diff options
author | John Keiser <john@johnkeiser.com> | 2015-12-11 16:24:05 -0800 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-12-14 11:04:19 -0800 |
commit | b60ad97446c064c71e5e1b03b94344eb0b5c136d (patch) | |
tree | f1fb8408d148a855d41a83234a688b12c6c7cf90 /lib/chef/property.rb | |
parent | f08d833465d9d2ea083d12a66958753afa2b1c7e (diff) | |
download | chef-b60ad97446c064c71e5e1b03b94344eb0b5c136d.tar.gz |
Don't warn when setting a property to nil unless its value wouldjk/updates2
actually change. Gets rid of cases where we are initializing a
resource with values from another resource.
Diffstat (limited to 'lib/chef/property.rb')
-rw-r--r-- | lib/chef/property.rb | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/chef/property.rb b/lib/chef/property.rb index b2658235f2..742eba42fd 100644 --- a/lib/chef/property.rb +++ b/lib/chef/property.rb @@ -251,16 +251,19 @@ class Chef return get(resource) end - # myprop nil is sometimes a get (backcompat) if value.nil? && !explicitly_accepts_nil?(resource) - # If you say "my_property nil" and the property explicitly accepts - # nil values, we consider this a get. - Chef.log_deprecation("#{name} nil currently does not overwrite the value of #{name}. This will change in Chef 13, and the value will be set to nil instead. Please change your code to explicitly accept nil using \"property :#{name}, [MyType, nil]\", or stop setting this value to nil.") - return get(resource) + # In Chef 12, value(nil) does a *get* instead of a set, so we + # warn if the value would have been changed. In Chef 13, it will be + # equivalent to value = nil. + result = get(resource) + if !result.nil? + Chef.log_deprecation("#{name} nil currently does not overwrite the value of #{name}. This will change in Chef 13, and the value will be set to nil instead. Please change your code to explicitly accept nil using \"property :#{name}, [MyType, nil]\", or stop setting this value to nil.") + end + result + else + # Anything else, such as myprop(value) is a set + set(resource, value) end - - # Anything else (myprop value) is a set - set(resource, value) end # |