diff options
author | Steven Danna <steve@opscode.com> | 2014-06-23 14:16:07 -0700 |
---|---|---|
committer | Steven Danna <steve@opscode.com> | 2014-06-23 14:19:54 -0700 |
commit | 75c2c4bfb2fda2c1cd3f8d092043d9dc8fbc7267 (patch) | |
tree | b07273570c5571dd5e6ea3c8a2709da09417f659 | |
parent | d111e820f1f3dba3e759f6f06bbeac30f8aa1389 (diff) | |
download | chef-75c2c4bfb2fda2c1cd3f8d092043d9dc8fbc7267.tar.gz |
Add url_for_checksum helper function to CookbookVersion class
This function makes it easier for 3rd-party users of this class to
determine the url for a given checksums. Since the URL is not
standard across server types (ChefZero uses file_store, ChefServer
uses bookshelf), the only way to get his information reliably is to
read it out of the metadata.
-rw-r--r-- | lib/chef/cookbook_version.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb index 3d8b9fb908..1f0311e33e 100644 --- a/lib/chef/cookbook_version.rb +++ b/lib/chef/cookbook_version.rb @@ -207,6 +207,14 @@ class Chef results end + def url_for_checksum(checksum) + Chef::CookbookVersion::COOKBOOK_SEGMENTS.each do |segment| + f = manifest[segment].find {|c| c["checksum"] == checksum } + break if f + end + f["url"] + end + def recipe_filenames=(*filenames) @recipe_filenames = filenames.flatten @recipe_filenames_by_name = filenames_by_name(recipe_filenames) |