Commit 6745c7b3 authored by danielsdeleo's avatar danielsdeleo Committed by Bryan McLellan
Browse files

[CHEF-1804] Add deprecation notice to 10.x tree for implicit set

This will trigger a warning when using code like node["foo"] = "value"

Warnings can be deactivated by setting
Chef::Config[:chef11_deprecation_warnings] to false
parent b7aa405b
......@@ -303,6 +303,9 @@ class Chef
cache_type "BasicFile"
cache_options({ :path => platform_specific_path("/var/chef/cache/checksums"), :skip_expires => true })
# Set to false to silence Chef 11 deprecation warnings:
chef11_deprecation_warnings true
# Arbitrary knife configuration data
......@@ -397,7 +397,7 @@ class Chef
# Lazy initializer for tags attribute
def tags
self[:tags] = [] unless attribute?(:tags)
self.set[:tags] = [] unless attribute?(:tags)
......@@ -318,7 +318,24 @@ class Chef
def []=(key, value)
# If we don't have one, then we'll pretend we're normal
@set_type ||= :normal
if @set_type.nil?
@set_type = :normal
Setting attributes without specifying a precedence is deprecated and will be
removed in Chef 11.0. To set attributes at normal precedence, change code like:
`node["key"] = "value"` # Not this
`node.set["key"] = "value"` # This
Called from:
warning_with_line_nrs = caller[0...3].inject(warning) do |msg, source_line|
msg << " #{source_line}\n"
Chef::Log.warn(warning_with_line_nrs) if Chef::Config[:chef11_deprecation_warnings]
if set_unless_value_present
if get_value(set_type_hash, key) != nil
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment