From b62e6ae14ddd9c60035f4ec314f4c6d0ab47777e Mon Sep 17 00:00:00 2001 From: Thom May Date: Tue, 23 Feb 2016 09:52:20 +0000 Subject: Ensure that chef-zero loads libraries recursively --- lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb | 2 +- lib/chef/cookbook/cookbook_version_loader.rb | 2 +- lib/chef/run_context/cookbook_compiler.rb | 1 + spec/integration/knife/chef_repository_file_system_spec.rb | 4 ++++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb index 3a08768baf..92295b4fe8 100644 --- a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb @@ -53,7 +53,7 @@ class Chef :attributes => { :ruby_only => true }, :definitions => { :ruby_only => true }, :recipes => { :ruby_only => true }, - :libraries => { :ruby_only => true }, + :libraries => { :recursive => true }, :templates => { :recursive => true }, :files => { :recursive => true }, :resources => { :ruby_only => true, :recursive => true }, diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb index 48fa6a03a1..d9b027f322 100644 --- a/lib/chef/cookbook/cookbook_version_loader.rb +++ b/lib/chef/cookbook/cookbook_version_loader.rb @@ -86,7 +86,7 @@ class Chef load_as(:attribute_filenames, "attributes", "*.rb") load_as(:definition_filenames, "definitions", "*.rb") load_as(:recipe_filenames, "recipes", "*.rb") - load_recursively_as(:library_filenames, "libraries", "*.rb") + load_recursively_as(:library_filenames, "libraries", "*") load_recursively_as(:template_filenames, "templates", "*") load_recursively_as(:file_filenames, "files", "*") load_recursively_as(:resource_filenames, "resources", "*.rb") diff --git a/lib/chef/run_context/cookbook_compiler.rb b/lib/chef/run_context/cookbook_compiler.rb index e8311a18a6..bdf3a1251c 100644 --- a/lib/chef/run_context/cookbook_compiler.rb +++ b/lib/chef/run_context/cookbook_compiler.rb @@ -186,6 +186,7 @@ class Chef def load_libraries_from_cookbook(cookbook_name) files_in_cookbook_by_segment(cookbook_name, :libraries).each do |filename| + next unless File.extname(filename) == ".rb" begin Chef::Log.debug("Loading cookbook #{cookbook_name}'s library file: #{filename}") Kernel.load(filename) diff --git a/spec/integration/knife/chef_repository_file_system_spec.rb b/spec/integration/knife/chef_repository_file_system_spec.rb index e431c7f612..cc538c98c0 100644 --- a/spec/integration/knife/chef_repository_file_system_spec.rb +++ b/spec/integration/knife/chef_repository_file_system_spec.rb @@ -231,6 +231,10 @@ EOM /cookbooks/cookbook1/files/c/e.json /cookbooks/cookbook1/libraries/ /cookbooks/cookbook1/libraries/a.rb +/cookbooks/cookbook1/libraries/b.json +/cookbooks/cookbook1/libraries/c/ +/cookbooks/cookbook1/libraries/c/d.rb +/cookbooks/cookbook1/libraries/c/e.json /cookbooks/cookbook1/providers/ /cookbooks/cookbook1/providers/a.rb /cookbooks/cookbook1/providers/c/ -- cgit v1.2.1