From 93c669196f53d21cf2b973b014c2cde4e0c3313a Mon Sep 17 00:00:00 2001 From: danielsdeleo Date: Tue, 24 Mar 2015 18:14:57 -0700 Subject: Handle cookbook artfact format differences when fetching cookbooks Cookbook artifacts differ in these ways: * the name field is the cookbook name instead of name+version * there is no "cookbook_name" field * cookbook artifacts don't have a json_class when downloaded from the server * there is an identifier field --- lib/chef/cookbook/remote_file_vendor.rb | 2 +- lib/chef/policy_builder/policyfile.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/chef/cookbook/remote_file_vendor.rb b/lib/chef/cookbook/remote_file_vendor.rb index 2ddce31001..9d895b168e 100644 --- a/lib/chef/cookbook/remote_file_vendor.rb +++ b/lib/chef/cookbook/remote_file_vendor.rb @@ -30,7 +30,7 @@ class Chef def initialize(manifest, rest) @manifest = manifest - @cookbook_name = @manifest[:cookbook_name] + @cookbook_name = @manifest[:cookbook_name] || @manifest[:name] @rest = rest end diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb index f85d72f121..0c7c07f9f3 100644 --- a/lib/chef/policy_builder/policyfile.rb +++ b/lib/chef/policy_builder/policyfile.rb @@ -370,7 +370,7 @@ class Chef def artifact_manifest_for(cookbook_name, lock_data) identifier = lock_data["identifier"] rel_url = "cookbook_artifacts/#{cookbook_name}/#{identifier}" - http_api.get(rel_url) + inflate_cbv_object(http_api.get(rel_url)) rescue Exception => e message = "Error loading cookbook #{cookbook_name} with identifier #{identifier} from #{rel_url}: #{e.class} - #{e.message}" err = Chef::Exceptions::CookbookNotFound.new(message) @@ -378,6 +378,10 @@ class Chef raise err end + def inflate_cbv_object(raw_manifest) + Chef::CookbookVersion.from_cb_artifact_data(raw_manifest) + end + end end end -- cgit v1.2.1