diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-06-17 21:07:08 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-08-12 11:29:16 -0700 |
commit | 35a63ddc192e50c45f6e94a3b270ed0e75c93668 (patch) | |
tree | fed93952978c3b75febae5d90f80e1f0cd5fcc8b /lib/chef/resource_collection.rb | |
parent | 84da5f7a45d7ccba250d160626e6da8762a7f222 (diff) | |
download | chef-35a63ddc192e50c45f6e94a3b270ed0e75c93668.tar.gz |
Add unified_mode switch for resources
This is inspired by "use_inline_resources".
Setting `unified_mode false` in a resource would be the existing
behavior with separate compile/converge phases.
Setting `unified_mode true` in a resource will eliminate the converge
phase. Reverse notifications and delayed notifications will still
fire. The resource action will behave like all resources are executing
at compile time.
As a aside, notifications have never worked for resources firing at
compile time. This implementation gets that behavior correct so
that notifications will work.
Of course forward immediate notifications to resources not yet declared will not
be possible.
Setting `resource_unified_mode_default true` in `Chef::Config` would
turn off the split compile/converge mode for every custom resource.
NOTE: This does not affect recipe mode at all.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/resource_collection.rb')
-rw-r--r-- | lib/chef/resource_collection.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/chef/resource_collection.rb b/lib/chef/resource_collection.rb index 3b6ff4297e..da675fc4de 100644 --- a/lib/chef/resource_collection.rb +++ b/lib/chef/resource_collection.rb @@ -32,6 +32,8 @@ class Chef include ResourceCollectionSerialization extend Forwardable + attr_accessor :unified_mode + attr_reader :resource_set, :resource_list attr_accessor :run_context @@ -41,6 +43,7 @@ class Chef @run_context = run_context @resource_set = ResourceSet.new @resource_list = ResourceList.new + @unified_mode = false end # @param resource [Chef::Resource] The resource to insert @@ -57,6 +60,9 @@ class Chef else resource_set.insert_as(resource) end + if unified_mode + run_context.runner.run_all_actions(resource) + end end def delete(key) |