summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-03-15 21:05:08 +0000
committerThom May <thom@may.lt>2016-03-15 21:05:08 +0000
commit47cd0cb9f2c14ced5a17ea0d1da34b9aeaaf36d8 (patch)
tree05cfad5447fbce497e545f4d059e6b9f3e0ba5ed
parente8b39b0aafd903bcca077d8e83b958ea4422d96a (diff)
parentb62e6ae14ddd9c60035f4ec314f4c6d0ab47777e (diff)
downloadchef-47cd0cb9f2c14ced5a17ea0d1da34b9aeaaf36d8.tar.gz
Merge pull request #4640 from chef/tm/zero_deep_libraries
Support libraries with sub directories
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb2
-rw-r--r--lib/chef/cookbook/cookbook_version_loader.rb2
-rw-r--r--lib/chef/run_context/cookbook_compiler.rb1
-rw-r--r--spec/integration/knife/chef_repository_file_system_spec.rb4
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 d69126ce6e..f7e5f058be 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/