summaryrefslogtreecommitdiff
path: root/lib/chef/cookbook_version.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2015-02-05 17:53:00 -0800
committerdanielsdeleo <dan@getchef.com>2015-02-11 10:52:49 -0800
commit677ca0d7e3366ea9b3b6a912c8c6c28d543e2046 (patch)
tree512473fe4a623586d86eee948efc43857d800d8e /lib/chef/cookbook_version.rb
parente3e9f1996131f287f0e6d8b344e658062003efe7 (diff)
downloadchef-677ca0d7e3366ea9b3b6a912c8c6c28d543e2046.tar.gz
Move remaining http relevant methods to CookbookManifest
Diffstat (limited to 'lib/chef/cookbook_version.rb')
-rw-r--r--lib/chef/cookbook_version.rb59
1 files changed, 26 insertions, 33 deletions
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 025828beb5..c26ab46565 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -63,14 +63,27 @@ class Chef
cookbook_manifest.update_from(new_manifest)
end
+ def save_url
+ cookbook_manifest.save_url
+ end
+
+ def force_save_url
+ cookbook_manifest.force_save_url
+ end
+
+ def to_hash
+ cookbook_manifest.to_hash
+ end
+
+ def to_json(*a)
+ cookbook_manifest.to_json
+ end
+
include Comparable
COOKBOOK_SEGMENTS = [ :resources, :providers, :recipes, :definitions, :libraries, :attributes, :files, :templates, :root_files ]
- # TODO: deprecate setter
attr_accessor :root_paths
-
- # TODO: deprecate setter for all *_filenames, only used when consuming JSON
attr_accessor :definition_filenames
attr_accessor :template_filenames
attr_accessor :file_filenames
@@ -81,8 +94,15 @@ class Chef
attr_accessor :name
attr_accessor :metadata_filenames
- # TODO: unused, deprecate
- attr_accessor :status
+ def status=(new_status)
+ Chef::Log.warn("Deprecated method `status' called from #{caller(1).first}. This method will be removed")
+ @status = new_status
+ end
+
+ def status
+ Chef::Log.warn("Deprecated method `status' called from #{caller(1).first}. This method will be removed")
+ @status
+ end
# A Chef::Cookbook::Metadata object. It has a setter that fixes up the
# metadata to add descriptions of the recipes contained in this
@@ -139,7 +159,7 @@ class Chef
@metadata_filenames = Array.new
@root_filenames = Array.new
- # TODO: unused, deprecate.
+ # deprecated
@status = :ready
@file_vendor = nil
@metadata = Chef::Cookbook::Metadata.new
@@ -448,19 +468,6 @@ class Chef
end
private :preferences_for_path
- def to_hash
- result = manifest.dup
- result['frozen?'] = frozen_version?
- result['chef_type'] = 'cookbook_version'
- result.to_hash
- end
-
- def to_json(*a)
- result = to_hash
- result['json_class'] = self.class.name
- Chef::JSONCompat.to_json(result, *a)
- end
-
def self.json_create(o)
cookbook_version = new(o["cookbook_name"])
# We want the Chef::Cookbook::Metadata object to always be inflated
@@ -516,20 +523,6 @@ class Chef
self.class.chef_server_rest
end
- # 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
chef_server_rest.delete_rest("cookbooks/#{name}/#{version}")
self