summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-10-18 18:02:14 -0700
committerGitHub <noreply@github.com>2016-10-18 18:02:14 -0700
commite2fd0bccf1004143c5a25f7034940d34515e6e0a (patch)
treef8d8bedec94b5b292e3a4febe6471ff33b4a000a
parent3926de3ebca29bf03a48452bce7fca5a5a2d3e85 (diff)
parent06b3dc20380fe003bafe7a13689537095a7337a7 (diff)
downloadchef-e2fd0bccf1004143c5a25f7034940d34515e6e0a.tar.gz
Merge pull request #5464 from chef/lcg/less-global-state
remove dependency on Chef.run_context global state
-rw-r--r--lib/chef/dsl/declare_resource.rb2
-rw-r--r--lib/chef/run_context.rb12
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/chef/dsl/declare_resource.rb b/lib/chef/dsl/declare_resource.rb
index ed3083e1ca..2ebef98bd4 100644
--- a/lib/chef/dsl/declare_resource.rb
+++ b/lib/chef/dsl/declare_resource.rb
@@ -47,7 +47,7 @@ class Chef
when Chef::RunContext
rc
when :root
- Chef.run_context
+ run_context.root_run_context
when :parent
run_context.parent_run_context
else
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index 5d29f766c9..626977b09f 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -85,6 +85,17 @@ class Chef
attr_reader :parent_run_context
#
+ # The root run context.
+ #
+ # @return [Chef::RunContext] The root run context.
+ #
+ def root_run_context
+ rc = self
+ rc = rc.parent_run_context until rc.parent_run_context.nil?
+ rc
+ end
+
+ #
# The collection of resources intended to be converged (and able to be
# notified).
#
@@ -653,6 +664,7 @@ ERROR_MESSAGE
notifies_immediately
notifies_delayed
parent_run_context
+ root_run_context
resource_collection
resource_collection=
}.map { |x| x.to_sym }