summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Danna <steve@opscode.com>2014-06-23 14:16:07 -0700
committerSteven Danna <steve@opscode.com>2014-06-23 14:19:54 -0700
commit75c2c4bfb2fda2c1cd3f8d092043d9dc8fbc7267 (patch)
treeb07273570c5571dd5e6ea3c8a2709da09417f659
parentd111e820f1f3dba3e759f6f06bbeac30f8aa1389 (diff)
downloadchef-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.rb8
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)