summaryrefslogtreecommitdiff
path: root/lib/chef/chef_class.rb
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2016-10-14 16:46:51 +0100
committerThom May <thom@chef.io>2016-11-16 16:28:15 +0000
commit64b8b0efd90e59ad609ba30fe4bc7ff19e70e940 (patch)
tree779c33247a0617eed1db6b6a662635a0f91d37d3 /lib/chef/chef_class.rb
parentbedcbd5f52448d24fdd7ab26ab79185c011beee3 (diff)
downloadchef-64b8b0efd90e59ad609ba30fe4bc7ff19e70e940.tar.gz
Structure deprecations with additional metadatatm/deprecation_with_url
This adds URLs to each class of deprecation, and correctly prints and formats them for maximum user efficiency. We also provide the URL to the data collector for Visibility to ingest. Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'lib/chef/chef_class.rb')
-rw-r--r--lib/chef/chef_class.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/chef/chef_class.rb b/lib/chef/chef_class.rb
index 0bb15c03ca..8c766699fc 100644
--- a/lib/chef/chef_class.rb
+++ b/lib/chef/chef_class.rb
@@ -198,26 +198,35 @@ class Chef
#
# Emit a deprecation message.
#
- # @param message The message to send.
+ # @param type The message to send. This should be a symbol, referring to
+ # a class defined in Chef::Deprecated
+ # @param message An explicit message to display, rather than the generic one
+ # associated with the deprecation.
# @param location The location. Defaults to the caller who called you (since
# generally the person who triggered the check is the one that needs to be
# fixed).
#
# @example
- # Chef.deprecation("Deprecated!")
+ # Chef.deprecated(:my_deprecation, message: "This is deprecated!")
#
# @api private this will likely be removed in favor of an as-yet unwritten
# `Chef.log`
- def log_deprecation(message, location = nil)
+ def deprecated(type, message, location = nil)
location ||= Chef::Log.caller_location
+ deprecation = Chef::Deprecated.create(type, message, location)
# `run_context.events` is the primary deprecation target if we're in a
# run. If we are not yet in a run, print to `Chef::Log`.
if run_context && run_context.events
- run_context.events.deprecation(message, location)
+ run_context.events.deprecation(deprecation, location)
else
- Chef::Log.deprecation(message, location)
+ Chef::Log.deprecation(deprecation, location)
end
end
+
+ def log_deprecation(message, location = nil)
+ location ||= Chef::Log.caller_location
+ Chef.deprecated(:generic, message, location)
+ end
end
# @api private Only for test dependency injection; not evenly implemented as yet.