summaryrefslogtreecommitdiff
path: root/lib/chef_zero/server.rb
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2016-01-13 10:28:42 -0800
committerJohn Keiser <john@johnkeiser.com>2016-01-14 15:46:08 -0800
commiteb0c969eba62201bede1b60575197907c942331f (patch)
treea5b212005b515ce404f16d8f0ff2f78997ac490a /lib/chef_zero/server.rb
parentcf1bd23d5853bf71c8ff256a12b90beba556e1e9 (diff)
downloadchef-zero-eb0c969eba62201bede1b60575197907c942331f.tar.gz
Fix cookbook_artifact
Diffstat (limited to 'lib/chef_zero/server.rb')
-rw-r--r--lib/chef_zero/server.rb33
1 files changed, 19 insertions, 14 deletions
diff --git a/lib/chef_zero/server.rb b/lib/chef_zero/server.rb
index c96150e..3326420 100644
--- a/lib/chef_zero/server.rb
+++ b/lib/chef_zero/server.rb
@@ -473,20 +473,25 @@ module ChefZero
end
end
- if contents['cookbooks']
- contents['cookbooks'].each_pair do |name_version, cookbook|
- if name_version =~ /(.+)-(\d+\.\d+\.\d+)$/
- cookbook_data = ChefData::CookbookData.to_hash(cookbook, $1, $2)
- else
- cookbook_data = ChefData::CookbookData.to_hash(cookbook, name_version)
- end
- raise "No version specified" if !cookbook_data[:version]
- data_store.create_dir(['organizations', org_name, 'cookbooks'], cookbook_data[:cookbook_name], :recursive)
- data_store.set(['organizations', org_name, 'cookbooks', cookbook_data[:cookbook_name], cookbook_data[:version]], FFI_Yajl::Encoder.encode(cookbook_data, :pretty => true), :create)
- cookbook_data.values.each do |files|
- next unless files.is_a? Array
- files.each do |file|
- data_store.set(['organizations', org_name, 'file_store', 'checksums', file[:checksum]], get_file(cookbook, file[:path]), :create)
+ %w(cookbooks cookbook_artifacts).each do |cookbook_type|
+ if contents[cookbook_type]
+ contents[cookbook_type].each_pair do |name_version, cookbook|
+ if cookbook_type == 'cookbook_artifacts'
+ name, dash, identifier = name_version.rpartition('-')
+ cookbook_data = ChefData::CookbookData.to_hash(cookbook, name, identifier)
+ elsif name_version =~ /(.+)-(\d+\.\d+\.\d+)$/
+ cookbook_data = ChefData::CookbookData.to_hash(cookbook, $1, $2)
+ else
+ cookbook_data = ChefData::CookbookData.to_hash(cookbook, name_version)
+ end
+ raise "No version specified" if !cookbook_data[:version]
+ data_store.create_dir(['organizations', org_name, cookbook_type], cookbook_data[:cookbook_name], :recursive)
+ data_store.set(['organizations', org_name, cookbook_type, cookbook_data[:cookbook_name], cookbook_data[:version]], FFI_Yajl::Encoder.encode(cookbook_data, :pretty => true), :create)
+ cookbook_data.values.each do |files|
+ next unless files.is_a? Array
+ files.each do |file|
+ data_store.set(['organizations', org_name, 'file_store', 'checksums', file[:checksum]], get_file(cookbook, file[:path]), :create)
+ end
end
end
end