summaryrefslogtreecommitdiff
path: root/lib/chef/cookbook_manifest.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2015-03-24 17:53:56 -0700
committerdanielsdeleo <dan@getchef.com>2015-03-25 08:13:34 -0700
commita6fbf127d3eeb38d73fa4b9aec98ef34cf897f85 (patch)
treea0eeadd9ae0a6bb4887b1c8f80e28e25952c7d7e /lib/chef/cookbook_manifest.rb
parent7ebb11ce0dbdec76562eb1008a8d85faad0cdaf4 (diff)
downloadchef-a6fbf127d3eeb38d73fa4b9aec98ef34cf897f85.tar.gz
Update policyfile URLs and cookbook artifact data format per RFC
Diffstat (limited to 'lib/chef/cookbook_manifest.rb')
-rw-r--r--lib/chef/cookbook_manifest.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/chef/cookbook_manifest.rb b/lib/chef/cookbook_manifest.rb
index 0d21e9725c..10654a4945 100644
--- a/lib/chef/cookbook_manifest.rb
+++ b/lib/chef/cookbook_manifest.rb
@@ -36,6 +36,7 @@ class Chef
def_delegator :@cookbook_version, :root_paths
def_delegator :@cookbook_version, :segment_filenames
def_delegator :@cookbook_version, :name
+ def_delegator :@cookbook_version, :identifier
def_delegator :@cookbook_version, :metadata
def_delegator :@cookbook_version, :full_name
def_delegator :@cookbook_version, :version
@@ -141,9 +142,16 @@ class Chef
# REST api. If there is an existing document on the server and it
# is marked frozen, a PUT will result in a 409 Conflict.
def save_url
- "#{cookbook_url_path}/#{name}/#{version}"
+ if policy_mode?
+ "#{named_cookbook_url}/#{identifier}"
+ else
+ "#{named_cookbook_url}/#{version}"
+ end
end
+ def named_cookbook_url
+ "#{cookbook_url_path}/#{name}"
+ end
# Adds the `force=true` parameter to the upload URL. This allows
# the user to overwrite a frozen cookbook (a PUT against the
# normal #save_url raises a 409 Conflict in this case).
@@ -214,10 +222,16 @@ class Chef
end
end
- manifest[:cookbook_name] = name.to_s
manifest[:metadata] = metadata
manifest[:version] = metadata.version
- manifest[:name] = full_name
+
+ if policy_mode?
+ manifest[:name] = name.to_s
+ manifest[:identifier] = identifier
+ else
+ manifest[:name] = full_name
+ manifest[:cookbook_name] = name.to_s
+ end
@manifest_records_by_path = extract_manifest_records_by_path(manifest)
@manifest = manifest