summaryrefslogtreecommitdiff
path: root/lib/chef/run_context
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2012-11-29 16:28:40 -0800
committerdanielsdeleo <dan@opscode.com>2012-11-30 14:51:48 -0800
commit549d048726dd27d88024334d31a85bc27bc527d4 (patch)
tree570e6b89b6042006010f0938065fe6eff9b90120 /lib/chef/run_context
parentd638ce43c7cf2208ff0db16db695212b7609b481 (diff)
downloadchef-549d048726dd27d88024334d31a85bc27bc527d4.tar.gz
[CHEF-3376] move recipe compilation to CookbookCompiler
Diffstat (limited to 'lib/chef/run_context')
-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