summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-12-03 13:26:30 -0800
committerJohn Keiser <john@johnkeiser.com>2015-12-09 10:26:08 -0800
commit9b0a4fd24e9939f95082f0fb7739f298a5791432 (patch)
tree66c084283e35eb35247d94eaadeae3b5544014a1
parentf49b514610f954945f1eb425a751e70ce784e3d1 (diff)
downloadchef-9b0a4fd24e9939f95082f0fb7739f298a5791432.tar.gz
immediately_before -> before
-rw-r--r--lib/chef/resource.rb20
-rw-r--r--lib/chef/run_context.rb28
-rw-r--r--lib/chef/runner.rb12
-rw-r--r--spec/functional/notifications_spec.rb14
-rw-r--r--spec/support/shared/integration/integration_helper.rb2
5 files changed, 38 insertions, 38 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 634d00feef..863d357561 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -209,7 +209,7 @@ class Chef
# actions have been run. This is the default.
# - `immediate`, `immediately`: Will run the action on the other resource
# immediately (before any other action is run).
- # - `immediately_before`: Will run the action on the other resource
+ # - `before`: Will run the action on the other resource
# immediately *before* the action is actually run.
#
# @example Resource by string
@@ -253,11 +253,11 @@ class Chef
notifies_delayed(action, resource)
when 'immediate', 'immediately'
notifies_immediately(action, resource)
- when 'immediately_before'
- notifies_immediately_before(action, resource)
+ when 'before'
+ notifies_before(action, resource)
else
raise ArgumentError, "invalid timing: #{timing} for notifies(#{action}, #{resources.inspect}, #{timing}) resource #{self} "\
- "Valid timings are: :delayed, :immediate, :immediately, :immediately_before"
+ "Valid timings are: :delayed, :immediate, :immediately, :before"
end
end
@@ -281,7 +281,7 @@ class Chef
# actions have been run. This is the default.
# - `immediate`, `immediately`: The action will run immediately following
# the other resource being updated.
- # - `immediately_before`: The action will run immediately before the
+ # - `before`: The action will run immediately before the
# other resource is updated.
#
# @example Resources by string
@@ -1244,7 +1244,7 @@ class Chef
# resolve_resource_reference on each in turn, causing them to
# resolve lazy/forward references.
def resolve_notification_references
- run_context.immediately_before_notifications(self).each { |n|
+ run_context.before_notifications(self).each { |n|
n.resolve_resource_reference(run_context.resource_collection)
}
run_context.immediate_notifications(self).each { |n|
@@ -1256,8 +1256,8 @@ class Chef
end
# Helper for #notifies
- def notifies_immediately_before(action, resource_spec)
- run_context.notifies_immediately_before(Notification.new(resource_spec, action, self))
+ def notifies_before(action, resource_spec)
+ run_context.notifies_before(Notification.new(resource_spec, action, self))
end
# Helper for #notifies
@@ -1355,8 +1355,8 @@ class Chef
"#{declared_type}[#{@name}]"
end
- def immediately_before_notifications
- run_context.immediately_before_notifications(self)
+ def before_notifications
+ run_context.before_notifications(self)
end
def immediate_notifications
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index b725857bc5..6e02f47ff1 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -104,13 +104,13 @@ class Chef
#
#
- # A Hash containing the immediately_before notifications triggered by resources
+ # A Hash containing the before notifications triggered by resources
# during the converge phase of the chef run.
#
# @return [Hash[String, Array[Chef::Resource::Notification]]] A hash from
# <notifying resource name> => <list of notifications it sent>
#
- attr_reader :immediately_before_notification_collection
+ attr_reader :before_notification_collection
#
# A Hash containing the immediate notifications triggered by resources
@@ -173,22 +173,22 @@ class Chef
def initialize_child_state
@audits = {}
@resource_collection = Chef::ResourceCollection.new
- @immediately_before_notification_collection = Hash.new {|h,k| h[k] = []}
+ @before_notification_collection = Hash.new {|h,k| h[k] = []}
@immediate_notification_collection = Hash.new {|h,k| h[k] = []}
@delayed_notification_collection = Hash.new {|h,k| h[k] = []}
end
#
- # Adds an immediately_before notification to the +immediately_before_notification_collection+.
+ # Adds an before notification to the +before_notification_collection+.
#
# @param [Chef::Resource::Notification] The notification to add.
#
- def notifies_immediately_before(notification)
+ def notifies_before(notification)
nr = notification.notifying_resource
if nr.instance_of?(Chef::Resource)
- immediately_before_notification_collection[nr.name] << notification
+ before_notification_collection[nr.name] << notification
else
- immediately_before_notification_collection[nr.declared_key] << notification
+ before_notification_collection[nr.declared_key] << notification
end
end
@@ -221,18 +221,18 @@ class Chef
end
#
- # Get the list of immediately_before notifications sent by the given resource.
+ # Get the list of before notifications sent by the given resource.
#
# TODO seriously, this is actually wrong. resource.name is not unique,
# you need the type as well.
#
# @return [Array[Notification]]
#
- def immediately_before_notifications(resource)
+ def before_notifications(resource)
if resource.instance_of?(Chef::Resource)
- return immediately_before_notification_collection[resource.name]
+ return before_notification_collection[resource.name]
else
- return immediately_before_notification_collection[resource.declared_key]
+ return before_notification_collection[resource.declared_key]
end
end
@@ -648,13 +648,13 @@ ERROR_MESSAGE
immediate_notification_collection
immediate_notification_collection=
immediate_notifications
- immediately_before_notification_collection
- immediately_before_notifications
+ before_notification_collection
+ before_notifications
include_recipe
initialize_child_state
load_recipe
load_recipe_file
- notifies_immediately_before
+ notifies_before
notifies_immediately
notifies_delayed
parent_run_context
diff --git a/lib/chef/runner.rb b/lib/chef/runner.rb
index 50554dcdbc..e1b4e98f89 100644
--- a/lib/chef/runner.rb
+++ b/lib/chef/runner.rb
@@ -47,22 +47,22 @@ class Chef
# execute it.
def run_action(resource, action, notification_type=nil, notifying_resource=nil)
- # If there are any immediately_before notifications, why-run the resource
+ # If there are any before notifications, why-run the resource
# and notify anyone who needs notifying
- if !run_context.immediately_before_notifications(resource).empty?
+ if !run_context.before_notifications(resource).empty?
whyrun_before = Chef::Config[:why_run]
begin
Chef::Config[:why_run] = true
- Chef::Log.info("#{resource} running why-run #{action} action to support immediately_before action")
+ Chef::Log.info("#{resource} running why-run #{action} action to support before action")
resource.run_action(action, notification_type, notifying_resource)
ensure
Chef::Config[:why_run] = whyrun_before
end
if resource.updated_by_last_action?
- run_context.immediately_before_notifications(resource).each do |notification|
- Chef::Log.info("#{resource} sending #{notification.action} action to #{notification.resource} (immediately_before)")
- run_action(notification.resource, notification.action, :immediately_before, resource)
+ run_context.before_notifications(resource).each do |notification|
+ Chef::Log.info("#{resource} sending #{notification.action} action to #{notification.resource} (before)")
+ run_action(notification.resource, notification.action, :before, resource)
end
end
diff --git a/spec/functional/notifications_spec.rb b/spec/functional/notifications_spec.rb
index 42702a8bb2..f14f35ebba 100644
--- a/spec/functional/notifications_spec.rb
+++ b/spec/functional/notifications_spec.rb
@@ -74,11 +74,11 @@ describe "Notifications" do
runner.converge
end
- it "should notify from one resource to another immediately_before" do
+ it "should notify from one resource to another before" do
log_resource = recipe.declare_resource(:log, "log") do
message "This is a log message"
action :write
- notifies :install, "package[vim]", :immediately_before
+ notifies :install, "package[vim]", :before
end
update_action(log_resource, 2)
@@ -102,19 +102,19 @@ describe "Notifications" do
expect(actions).to eq [
# First it runs why-run to check if the resource would update
{ resource: log_resource.to_s, action: :write, why_run: true },
- # Then it runs the immediately_before action
- { resource: package_resource.to_s, action: :install, notification_type: :immediately_before, notifying_resource: log_resource.to_s },
+ # Then it runs the before action
+ { resource: package_resource.to_s, action: :install, notification_type: :before, notifying_resource: log_resource.to_s },
# Then it runs the actual action
{ resource: log_resource.to_s, action: :write },
{ resource: package_resource.to_s, action: :nothing }
]
end
- it "should not notify from one resource to another immediately_before if the resource is not updated" do
+ it "should not notify from one resource to another before if the resource is not updated" do
log_resource = recipe.declare_resource(:log, "log") do
message "This is a log message"
action :write
- notifies :install, "package[vim]", :immediately_before
+ notifies :install, "package[vim]", :before
end
package_resource = recipe.declare_resource(:package, "vim") do
@@ -137,7 +137,7 @@ describe "Notifications" do
expect(actions).to eq [
# First it runs why-run to check if the resource would update
{ resource: log_resource.to_s, action: :write, why_run: true },
- # Then it does NOT run the immediately_before action
+ # Then it does NOT run the before action
# Then it runs the actual action
{ resource: log_resource.to_s, action: :write },
{ resource: package_resource.to_s, action: :nothing }
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb
index f5a1647b8f..7d62a698d8 100644
--- a/spec/support/shared/integration/integration_helper.rb
+++ b/spec/support/shared/integration/integration_helper.rb
@@ -29,7 +29,7 @@ require 'spec_helper'
module Cheffish
class BasicChefClient
- def_delegators :@run_context, :immediately_before_notifications
+ def_delegators :@run_context, :before_notifications
end
end