summaryrefslogtreecommitdiff
path: root/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb
diff options
context:
space:
mode:
authorHo-Sheng Hsiao <hosh@opscode.com>2013-02-21 14:02:08 -0800
committerJohn Keiser <jkeiser@opscode.com>2013-06-07 13:12:27 -0700
commit8f8c02dfa5927c74e2cb31017b76bb2543a7dd53 (patch)
tree0aa04c3d90132482a845f275db133da09a44a838 /lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb
parent0cef48ac97c3b881dbc67a5758338111959cc6e6 (diff)
downloadchef-8f8c02dfa5927c74e2cb31017b76bb2543a7dd53.tar.gz
[COOKBOOKS] Added symlinked proxy hack
- Rather than backporting CHEF-3307, we add a hack here to make versioned cookbook work - When cookbooks_dir attempts to upload a versioned cookbook, it will: (1) Create a temporary directory (2) Symlink a canonical cookbook name to the versioned cookbook. ( /tmp/x -> /path/cookbooks/x-1.0.0 ) (3) Upload the proxy (4) Remove the temporary directory This makes the versioned cookbook compatible with Chef 11-stable and 10-stable.
Diffstat (limited to 'lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb')
-rw-r--r--lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb b/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb
index 222b8bd861..e560b1bdb8 100644
--- a/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb
@@ -1,5 +1,6 @@
#
# Author:: John Keiser (<jkeiser@opscode.com>)
+# Author:: Ho-Sheng Hsiao (<hosh@opscode.com>)
# Copyright:: Copyright (c) 2012 Opscode, Inc.
# License:: Apache License, Version 2.0
#
@@ -58,13 +59,11 @@ class Chef
# as the directory name, with the version tag.
if Chef::Config[:versioned_cookbooks]
- name_match = Chef::ChefFS::FileSystem::CookbookDir::VALID_VERSIONED_COOKBOOK_NAME.match(File.basename(file_path))
- fail "When versioned_cookbooks mode is on, cookbook #{file_path} must match format <cookbook_name>-x.y.z" if name_match.nil?
-
- canonical_cookbook_name = name_match[1]
+ _canonical_name = canonical_cookbook_name(File.basename(file_path))
+ fail "When versioned_cookbooks mode is on, cookbook #{file_path} must match format <cookbook_name>-x.y.z" unless _canonical_name
# Warning, leaky abstraction
- loader.instance_variable_set(:@cookbook_name, canonical_cookbook_name)
+ loader.instance_variable_set(:@cookbook_name, _canonical_name)
end
loader.load_cookbooks
@@ -79,6 +78,16 @@ class Chef
nil
end
+ def self.canonical_cookbook_name(entry_name)
+ name_match = Chef::ChefFS::FileSystem::CookbookDir::VALID_VERSIONED_COOKBOOK_NAME.match(entry_name)
+ return nil if name_match.nil?
+ return name_match[1]
+ end
+
+ def canonical_cookbook_name(entry_name)
+ self.class.canonical_cookbook_name(entry_name)
+ end
+
def children
@children ||=
Dir.entries(file_path).