summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/run_context.rb21
-rw-r--r--lib/chef/run_context/cookbook_compiler.rb27
-rw-r--r--spec/unit/run_context/cookbook_compiler_spec.rb4
3 files changed, 30 insertions, 22 deletions
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index c9aea18a13..b5d4f1fe48 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -64,27 +64,6 @@ class Chef
def load(run_list_expansion)
compiler = CookbookCompiler.new(self, run_list_expansion, events)
compiler.compile
-
- @events.recipe_load_start(run_list_expansion.recipes.size)
- run_list_expansion.recipes.each do |recipe|
- begin
- include_recipe(recipe)
- rescue Chef::Exceptions::RecipeNotFound => e
- @events.recipe_not_found(e)
- raise
- rescue Exception => e
- path = resolve_recipe(recipe)
- @events.recipe_file_load_failed(path, e)
- raise
- end
- end
- @events.recipe_load_complete
- end
-
- def resolve_recipe(recipe_name)
- cookbook_name, recipe_short_name = Chef::Recipe.parse_recipe_name(recipe_name)
- cookbook = cookbook_collection[cookbook_name]
- cookbook.recipe_filenames_by_name[recipe_short_name]
end
# Looks up an attribute file given the +cookbook_name+ and
diff --git a/lib/chef/run_context/cookbook_compiler.rb b/lib/chef/run_context/cookbook_compiler.rb
index 5192fab9b4..4c70ea92b9 100644
--- a/lib/chef/run_context/cookbook_compiler.rb
+++ b/lib/chef/run_context/cookbook_compiler.rb
@@ -71,7 +71,7 @@ class Chef
compile_attributes
compile_lwrps
compile_resource_definitions
- #compile_recipes
+ compile_recipes
end
# Extracts the cookbook names from the expanded run list, then iterates
@@ -130,6 +130,23 @@ class Chef
@events.definition_load_complete
end
+ def compile_recipes
+ @events.recipe_load_start(run_list_expansion.recipes.size)
+ run_list_expansion.recipes.each do |recipe|
+ begin
+ @run_context.load_recipe(recipe)
+ rescue Chef::Exceptions::RecipeNotFound => e
+ @events.recipe_not_found(e)
+ raise
+ rescue Exception => e
+ path = resolve_recipe(recipe)
+ @events.recipe_file_load_failed(path, e)
+ raise
+ end
+ end
+ @events.recipe_load_complete
+ end
+
private
def load_attributes_from_cookbook(cookbook_name)
@@ -247,6 +264,14 @@ class Chef
cookbook.metadata.dependencies.keys.sort.each(&block)
end
+ # Given a +recipe_name+, finds the file associated with the recipe.
+ def resolve_recipe(recipe_name)
+ cookbook_name, recipe_short_name = Chef::Recipe.parse_recipe_name(recipe_name)
+ cookbook = cookbook_collection[cookbook_name]
+ cookbook.recipe_filenames_by_name[recipe_short_name]
+ end
+
+
end
end
diff --git a/spec/unit/run_context/cookbook_compiler_spec.rb b/spec/unit/run_context/cookbook_compiler_spec.rb
index 26b060f5c6..099354ae25 100644
--- a/spec/unit/run_context/cookbook_compiler_spec.rb
+++ b/spec/unit/run_context/cookbook_compiler_spec.rb
@@ -174,4 +174,8 @@ describe Chef::RunContext::CookbookCompiler do
end
+ describe "loading recipes" do
+ # Tests for this behavior are in RunContext's tests
+ end
+
end