summaryrefslogtreecommitdiff
path: root/lib/chef/run_context/cookbook_compiler.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/run_context/cookbook_compiler.rb')
-rw-r--r--lib/chef/run_context/cookbook_compiler.rb27
1 files changed, 26 insertions, 1 deletions
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