summaryrefslogtreecommitdiff
path: root/lib/chef/event_dispatch
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-08-31 14:38:50 -0700
committerJohn Keiser <john@johnkeiser.com>2015-09-01 19:30:43 -0700
commit25dac92eeb1ffa83ec549bfed0b19672c5847d80 (patch)
treef5292bfb261d40f1bbe3bdfa2845de87245f78d4 /lib/chef/event_dispatch
parentad8fd4d65b48519ac154ad9bf9774322b0c6d902 (diff)
downloadchef-25dac92eeb1ffa83ec549bfed0b19672c5847d80.tar.gz
Pass deprecations through formatter instead of logs
Diffstat (limited to 'lib/chef/event_dispatch')
-rw-r--r--lib/chef/event_dispatch/base.rb15
-rw-r--r--lib/chef/event_dispatch/dispatcher.rb4
2 files changed, 13 insertions, 6 deletions
diff --git a/lib/chef/event_dispatch/base.rb b/lib/chef/event_dispatch/base.rb
index 0ae5101029..1c9a58be23 100644
--- a/lib/chef/event_dispatch/base.rb
+++ b/lib/chef/event_dispatch/base.rb
@@ -47,14 +47,19 @@ class Chef
def ohai_completed(node)
end
- # Already have a client key, assuming this node has registered.
+ # Announce that we're not going to register the client. Generally because
+ # we already have the private key, or because we're deliberately not using
+ # a key.
def skipping_registration(node_name, config)
end
- # About to attempt to register as +node_name+
+ # About to attempt to create a private key registered to the server with
+ # client +node_name+.
def registration_start(node_name, config)
end
+ # Successfully created the private key and registered this client with the
+ # server.
def registration_completed
end
@@ -340,7 +345,6 @@ class Chef
def resource_completed(resource)
end
-
# A stream has opened.
def stream_opened(stream, options = {})
end
@@ -376,8 +380,9 @@ class Chef
def whyrun_assumption(action, resource, message)
end
- ## TODO: deprecation warning. this way we can queue them up and present
- # them all at once.
+ # Emit a message about something being deprecated.
+ def deprecation(message, location=caller(2..2)[0])
+ end
# An uncategorized message. This supports the case that a user needs to
# pass output that doesn't fit into one of the callbacks above. Note that
diff --git a/lib/chef/event_dispatch/dispatcher.rb b/lib/chef/event_dispatch/dispatcher.rb
index 9e17d78507..0c5b27514c 100644
--- a/lib/chef/event_dispatch/dispatcher.rb
+++ b/lib/chef/event_dispatch/dispatcher.rb
@@ -28,6 +28,9 @@ class Chef
# Define a method that will be forwarded to all
def self.def_forwarding_method(method_name)
define_method(method_name) do |*args|
+ if method_name == :deprecation && args.size == 1
+ args << caller(2..2)[0]
+ end
@subscribers.each do |s|
# Skip new/unsupported event names.
if s.respond_to?(method_name)
@@ -49,4 +52,3 @@ class Chef
end
end
end
-