diff options
author | Serdar Sutay <serdar@opscode.com> | 2014-10-10 12:40:45 -0700 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2014-10-10 12:40:45 -0700 |
commit | 18b555fb4dbf848ebfd274a5ceeda1b6a2427efd (patch) | |
tree | 58a3a3375214752472ad00d1ba4349dd086d2fe0 | |
parent | fa6e449b9e01cb4c2c145c1dac6ff054910dc12d (diff) | |
parent | 56246eef11d1c578f2bc9dbc92259565964f03f3 (diff) | |
download | chef-18b555fb4dbf848ebfd274a5ceeda1b6a2427efd.tar.gz |
Merge pull request #2129 from JeanMertz/library_subfolders
[CHEF-672] load library folder recursively
5 files changed, 18 insertions, 3 deletions
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb index 5481ba7ddc..bcbfcbeec8 100644 --- a/lib/chef/cookbook/cookbook_version_loader.rb +++ b/lib/chef/cookbook/cookbook_version_loader.rb @@ -81,7 +81,7 @@ class Chef load_as(:attribute_filenames, 'attributes', '*.rb') load_as(:definition_filenames, 'definitions', '*.rb') load_as(:recipe_filenames, 'recipes', '*.rb') - load_as(:library_filenames, 'libraries', '*.rb') + load_recursively_as(:library_filenames, 'libraries', '*.rb') load_recursively_as(:template_filenames, "templates", "*") load_recursively_as(:file_filenames, "files", "*") load_recursively_as(:resource_filenames, "resources", "*.rb") diff --git a/spec/data/cookbooks/openldap/libraries/openldap.rb b/spec/data/cookbooks/openldap/libraries/openldap.rb new file mode 100644 index 0000000000..6a3f058f95 --- /dev/null +++ b/spec/data/cookbooks/openldap/libraries/openldap.rb @@ -0,0 +1,4 @@ +require_relative './openldap/version.rb' + +class OpenLDAP +end diff --git a/spec/data/cookbooks/openldap/libraries/openldap/version.rb b/spec/data/cookbooks/openldap/libraries/openldap/version.rb new file mode 100644 index 0000000000..4bff12b01c --- /dev/null +++ b/spec/data/cookbooks/openldap/libraries/openldap/version.rb @@ -0,0 +1,3 @@ +class OpenLDAP + VERSION = '8.9.10' +end diff --git a/spec/unit/cookbook/cookbook_version_loader_spec.rb b/spec/unit/cookbook/cookbook_version_loader_spec.rb index 5772c5352d..4ba4e1de57 100644 --- a/spec/unit/cookbook/cookbook_version_loader_spec.rb +++ b/spec/unit/cookbook/cookbook_version_loader_spec.rb @@ -57,6 +57,11 @@ describe Chef::Cookbook::CookbookVersionLoader do expect(loaded_cookbook.recipe_filenames).to include(full_path("/recipes/return.rb")) end + it "loads libraries" do + expect(loaded_cookbook.library_filenames).to include(full_path('/libraries/openldap.rb')) + expect(loaded_cookbook.library_filenames).to include(full_path('/libraries/openldap/version.rb')) + end + it "loads static files in the files/ dir" do expect(loaded_cookbook.file_filenames).to include(full_path("/files/default/remotedir/remotesubdir/remote_subdir_file1.txt")) expect(loaded_cookbook.file_filenames).to include(full_path("/files/default/remotedir/remotesubdir/remote_subdir_file2.txt")) diff --git a/spec/unit/cookbook/syntax_check_spec.rb b/spec/unit/cookbook/syntax_check_spec.rb index cd1ce96716..4d22e0e920 100644 --- a/spec/unit/cookbook/syntax_check_spec.rb +++ b/spec/unit/cookbook/syntax_check_spec.rb @@ -28,10 +28,12 @@ describe Chef::Cookbook::SyntaxCheck do let(:syntax_check) { Chef::Cookbook::SyntaxCheck.new(cookbook_path) } let(:open_ldap_cookbook_files) do - %w{ attributes/default.rb + %w{ attributes/default.rb attributes/smokey.rb definitions/client.rb definitions/server.rb + libraries/openldap.rb + libraries/openldap/version.rb metadata.rb recipes/default.rb recipes/gigantor.rb @@ -44,9 +46,10 @@ describe Chef::Cookbook::SyntaxCheck do Chef::Log.level = :warn # suppress "Syntax OK" messages @attr_files = %w{default.rb smokey.rb}.map { |f| File.join(cookbook_path, 'attributes', f) } + @libr_files = %w{openldap.rb openldap/version.rb}.map { |f| File.join(cookbook_path, 'libraries', f) } @defn_files = %w{client.rb server.rb}.map { |f| File.join(cookbook_path, 'definitions', f)} @recipes = %w{default.rb gigantor.rb one.rb return.rb}.map { |f| File.join(cookbook_path, 'recipes', f) } - @ruby_files = @attr_files + @defn_files + @recipes + [File.join(cookbook_path, "metadata.rb")] + @ruby_files = @attr_files + @libr_files + @defn_files + @recipes + [File.join(cookbook_path, "metadata.rb")] basenames = %w{ helpers_via_partial_test.erb helper_test.erb openldap_stuff.conf.erb |