diff options
author | John Keiser <john@johnkeiser.com> | 2015-05-15 23:06:51 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-06-23 14:42:27 -0700 |
commit | e8a80c674bfb67b6839eb8498a73da61d0e9cdc0 (patch) | |
tree | 010453ba5d9d7f787a7c5e92afac0deee6cca0cd /lib/chef/provider/lwrp_base.rb | |
parent | 87a8b49efbccb6934ff2bacb8f8df53d1caf5e46 (diff) | |
download | chef-e8a80c674bfb67b6839eb8498a73da61d0e9cdc0.tar.gz |
Create the `action :name do ... end` syntax for Resource
Diffstat (limited to 'lib/chef/provider/lwrp_base.rb')
-rw-r--r-- | lib/chef/provider/lwrp_base.rb | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/lib/chef/provider/lwrp_base.rb b/lib/chef/provider/lwrp_base.rb index 94c79918b7..27b2042f2b 100644 --- a/lib/chef/provider/lwrp_base.rb +++ b/lib/chef/provider/lwrp_base.rb @@ -28,43 +28,6 @@ class Chef # Base class from which LWRP providers inherit. class LWRPBase < Provider - # Chef::Provider::LWRPBase::InlineResources - # Implementation of inline resource convergence for LWRP providers. See - # Provider::LWRPBase.use_inline_resources for a longer explanation. - # - # This code is restricted to a module so that it can be selectively - # applied to providers on an opt-in basis. - module InlineResources - - # Class methods for InlineResources. Overrides the `action` DSL method - # with one that enables inline resource convergence. - module ClassMethods - # Defines an action method on the provider, running the block to - # compile the resources, converging them, and then checking if any - # were updated (and updating new-resource if so) - def action(name, &block) - define_method("action_#{name}") do - begin - return_value = instance_eval(&block) - Chef::Runner.new(run_context).converge - return_value - ensure - if run_context.resource_collection.any? {|r| r.updated? } - new_resource.updated_by_last_action(true) - end - end - end - end - end - - # Our run context is a child of the main run context; that gives us a - # whole new resource collection and notification set. - def initialize(*args, &block) - super - @run_context = @run_context.create_child - end - end - include Chef::DSL::Recipe # These were previously provided by Chef::Mixin::RecipeDefinitionDSLCore. @@ -117,38 +80,6 @@ class Chef provider_class end - # Enables inline evaluation of resources in provider actions. - # - # Without this option, any resources declared inside the LWRP are added - # to the resource collection after the current position at the time the - # action is executed. Because they are added to the primary resource - # collection for the chef run, they can notify other resources outside - # the LWRP, and potentially be notified by resources outside the LWRP - # (but this is complicated by the fact that they don't exist until the - # provider executes). In this mode, it is impossible to correctly set the - # updated_by_last_action flag on the parent LWRP resource, since it - # executes and returns before its component resources are run. - # - # With this option enabled, each action creates a temporary run_context - # with its own resource collection, evaluates the action's code in that - # context, and then converges the resources created. If any resources - # were updated, then this provider's new_resource will be marked updated. - # - # In this mode, resources created within the LWRP cannot interact with - # external resources via notifies, though notifications to other - # resources within the LWRP will work. Delayed notifications are executed - # at the conclusion of the provider's action, *not* at the end of the - # main chef run. - # - # This mode of evaluation is experimental, but is believed to be a better - # set of tradeoffs than the append-after mode, so it will likely become - # the default in a future major release of Chef. - # - def use_inline_resources - extend InlineResources::ClassMethods - include InlineResources - end - # DSL for defining a provider's actions. def action(name, &block) define_method("action_#{name}") do |