summaryrefslogtreecommitdiff
path: root/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2016-01-13 10:08:44 -0800
committerJohn Keiser <john@johnkeiser.com>2016-01-13 13:40:13 -0800
commit333e1c781dd0a534ec7a06be0f88ae25ad4bc991 (patch)
tree3604945e61e4167379c62fcaa9d55ff551252641 /lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
parent6d97b322563f882a41fe6739a89d8075f63612d2 (diff)
downloadchef-333e1c781dd0a534ec7a06be0f88ae25ad4bc991.tar.gz
Split repository versioned and unversioned cookbooksjk/chef-fs-cookbook-refactor
Diffstat (limited to 'lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb')
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb24
1 files changed, 7 insertions, 17 deletions
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
index 1ebb8b42cf..e6557bd05d 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
@@ -28,25 +28,9 @@ class Chef
module FileSystem
module Repository
class ChefRepositoryFileSystemCookbookDir < ChefRepositoryFileSystemCookbookEntry
- def initialize(name, parent, file_path = nil)
- super(name, parent, file_path)
- end
-
def chef_object
begin
- loader = Chef::Cookbook::CookbookVersionLoader.new(file_path, parent.chefignore)
- # We need the canonical cookbook name if we are using versioned cookbooks, but we don't
- # want to spend a lot of time adding code to the main Chef libraries
- if root.versioned_cookbooks
- canonical_name = canonical_cookbook_name(File.basename(file_path))
- raise "When versioned_cookbooks mode is on, cookbook #{file_path} must match format <cookbook_name>-x.y.z" unless canonical_name
-
- # KLUDGE: We shouldn't have to use instance_variable_set
- loader.instance_variable_set(:@cookbook_name, canonical_name)
- end
-
- loader.load_cookbooks
- cb = loader.cookbook_version
+ cb = cookbook_version
if !cb
Chef::Log.error("Cookbook #{file_path} empty.")
raise "Cookbook #{file_path} empty."
@@ -98,6 +82,12 @@ class Chef
segment_info = Chef::ChefFS::FileSystem::ChefServer::CookbookDir::COOKBOOK_SEGMENT_INFO[child_name.to_sym] || {}
ChefRepositoryFileSystemCookbookEntry.new(child_name, self, nil, segment_info[:ruby_only], segment_info[:recursive])
end
+
+ def cookbook_version
+ loader = Chef::Cookbook::CookbookVersionLoader.new(file_path, parent.chefignore)
+ loader.load_cookbooks
+ cb = loader.cookbook_version
+ end
end
end
end