summaryrefslogtreecommitdiff
path: root/lib/chef/cookbook_version.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/cookbook_version.rb')
-rw-r--r--lib/chef/cookbook_version.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index b8f32a61bb..8d302eeec2 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -78,6 +78,16 @@ class Chef
attr_accessor :chef_server_rest
+ # The `identifier` field is used for cookbook_artifacts, which are
+ # organized on the chef server according to their content. If the
+ # policy_mode option to CookbookManifest is set to true it will include
+ # this field in the manifest Hash and in the upload URL.
+ #
+ # This field may be removed or have different behavior in the future, don't
+ # use it in 3rd party code.
+ # @api private
+ attr_accessor :identifier
+
# The first root path is the primary cookbook dir, from which metadata is loaded
def root_dir
root_paths[0]
@@ -458,6 +468,15 @@ class Chef
cookbook_version
end
+ def self.from_cb_artifact_data(o)
+ cookbook_version = new(o["name"])
+ # We want the Chef::Cookbook::Metadata object to always be inflated
+ cookbook_version.metadata = Chef::Cookbook::Metadata.from_hash(o["metadata"])
+ cookbook_version.manifest = o
+ cookbook_version.identifier = o["identifier"]
+ cookbook_version
+ end
+
# @deprecated This method was used by the Ruby Chef Server and is no longer
# needed. There is no replacement.
def generate_manifest_with_urls(&url_generator)