diff options
author | Tim Hinderliter <tim@opscode.com> | 2011-04-26 16:33:10 -0700 |
---|---|---|
committer | Tim Hinderliter <tim@opscode.com> | 2011-04-26 16:33:10 -0700 |
commit | f90e01f038bd1c443280e85d330c2648e5646698 (patch) | |
tree | 98828f7242218e08b4347eaeeb137cdf18fb3402 | |
parent | 9ca382bd433abc2cbbb92c7ae3f7a7d21be68121 (diff) | |
download | chef-f90e01f038bd1c443280e85d330c2648e5646698.tar.gz |
cookbook_version save -> save_url, force_save ->
force_save_url: these return a URL instead of
using Chef::REST object directly.
-rw-r--r-- | chef/lib/chef/cookbook_uploader.rb | 5 | ||||
-rw-r--r-- | chef/lib/chef/cookbook_version.rb | 27 |
2 files changed, 16 insertions, 16 deletions
diff --git a/chef/lib/chef/cookbook_uploader.rb b/chef/lib/chef/cookbook_uploader.rb index 02ee55be8f..cec41a5626 100644 --- a/chef/lib/chef/cookbook_uploader.rb +++ b/chef/lib/chef/cookbook_uploader.rb @@ -100,8 +100,11 @@ class Chef raise end end + # files are uploaded, so save the manifest - opts[:force] ? cookbook.force_save : cookbook.save + save_url = opts[:force] ? cookbook.force_save_url : cookbook.save_url + rest.put_rest(save_url, cookbook) + Chef::Log.info("Upload complete!") end diff --git a/chef/lib/chef/cookbook_version.rb b/chef/lib/chef/cookbook_version.rb index bce45578fb..117bb610a5 100644 --- a/chef/lib/chef/cookbook_version.rb +++ b/chef/lib/chef/cookbook_version.rb @@ -823,21 +823,18 @@ class Chef self.class.chef_server_rest end - # Save this object to the server via the REST api. If there is an existing - # document on the server and it is marked frozen, a - # Net::HTTPServerException will be raised for 409 Conflict. - def save - chef_server_rest.put_rest("cookbooks/#{name}/#{version}", self) - self - end - alias :create :save - - # Adds the `force=true` parameter to the upload. This allows the user to - # overwrite a frozen cookbook (normal #save raises a - # Net::HTTPServerException for 409 Conflict in this case). - def force_save - chef_server_rest.put_rest("cookbooks/#{name}/#{version}?force=true", self) - self + # Return the URL to save (PUT) this object to the server via the + # 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}" + 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" end def destroy |