summaryrefslogtreecommitdiff
path: root/lib/chef/cookbook_manifest.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2015-02-10 10:24:05 -0800
committerdanielsdeleo <dan@getchef.com>2015-02-11 10:52:49 -0800
commit06757d1307538f7b4d8ef4c57beedc7eff8b8bbe (patch)
tree12743d1fdc81e10d70b6e268233161fa7fc3a41d /lib/chef/cookbook_manifest.rb
parent20bc6b6e6faa8c3730eb59f3a999ec41ebb8a560 (diff)
downloadchef-06757d1307538f7b4d8ef4c57beedc7eff8b8bbe.tar.gz
Switch save URL based on policy mode flag
Diffstat (limited to 'lib/chef/cookbook_manifest.rb')
-rw-r--r--lib/chef/cookbook_manifest.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/chef/cookbook_manifest.rb b/lib/chef/cookbook_manifest.rb
index 417afbd82c..92f20664bd 100644
--- a/lib/chef/cookbook_manifest.rb
+++ b/lib/chef/cookbook_manifest.rb
@@ -39,8 +39,9 @@ class Chef
def_delegator :@cookbook_version, :version
def_delegator :@cookbook_version, :frozen_version?
- def initialize(cookbook_version)
+ def initialize(cookbook_version, policy_mode: false)
@cookbook_version = cookbook_version
+ @policy_mode = !!policy_mode
reset!
end
@@ -99,6 +100,10 @@ class Chef
@manifest_records_by_path
end
+ def policy_mode?
+ @policy_mode
+ end
+
def to_hash
result = manifest.dup
result['frozen?'] = frozen_version?
@@ -116,14 +121,14 @@ 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
- "cookbooks/#{name}/#{version}"
+ "#{cookbook_url_path}/#{name}/#{version}"
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).
def force_save_url
- "cookbooks/#{name}/#{version}?force=true"
+ "#{cookbook_url_path}/#{name}/#{version}?force=true"
end
# TODO: This is kind of terrible. investigate removing it
@@ -144,6 +149,10 @@ class Chef
private
+ def cookbook_url_path
+ policy_mode? ? "cookbook_artifacts" : "cookbooks"
+ end
+
# See #manifest for a description of the manifest return value.
# See #preferred_manifest_record for a description an individual manifest record.
def generate_manifest