diff options
author | Zachary Stevens <zts@cryptocracy.com> | 2012-10-14 21:01:28 +0700 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2013-04-12 12:34:55 -0700 |
commit | dbedaf4ea3e6163ed6a60cfc895b7f530fcec667 (patch) | |
tree | becfe9f1a939c73182c081dd8f4b6cb3b51a0097 | |
parent | 517f7c3d92af36aeefd92959d55519b09bf7c3b3 (diff) | |
download | chef-dbedaf4ea3e6163ed6a60cfc895b7f530fcec667.tar.gz |
[CHEF-3452] uploading frozen cookbook version explodes
This change make Chef::CookbookUploader for testing whether a cookbook
upload has failed due to a frozen version existing on the server.
This fixes a regression introduced by 7c7b4ea1.
-rw-r--r-- | lib/chef/cookbook_uploader.rb | 11 | ||||
-rw-r--r-- | lib/chef/knife/cookbook_upload.rb | 12 |
2 files changed, 13 insertions, 10 deletions
diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb index 69be03731e..9ba5b2bd8b 100644 --- a/lib/chef/cookbook_uploader.rb +++ b/lib/chef/cookbook_uploader.rb @@ -110,7 +110,16 @@ class Chef # files are uploaded, so save the manifest cookbooks.each do |cb| save_url = opts[:force] ? cb.force_save_url : cb.save_url - rest.put_rest(save_url, cb) + begin + rest.put_rest(save_url, cb) + rescue Net::HTTPServerException => e + case e.response.code + when "409" + raise Chef::Exceptions::CookbookFrozen, "Version #{cb.version} of cookbook #{cb.name} is frozen. Use --force to override." + else + raise + end + end end Chef::Log.info("Upload complete!") diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb index 5338e05f19..d4a66e6925 100644 --- a/lib/chef/knife/cookbook_upload.rb +++ b/lib/chef/knife/cookbook_upload.rb @@ -229,15 +229,9 @@ WARNING check_for_dependencies!(cb) end Chef::CookbookUploader.new(cookbooks, config[:cookbook_path], :force => config[:force]).upload_cookbooks - rescue Net::HTTPServerException => e - case e.response.code - when "409" - ui.error "Version #{cookbook.version} of cookbook #{cookbook.name} is frozen. Use --force to override." - Log.debug(e) - raise Exceptions::CookbookFrozen - else - raise - end + rescue Chef::Exceptions::CookbookFrozen => e + ui.error e + raise end def check_for_broken_links!(cookbook) |