diff options
author | Thom May <thom.may@betfair.com> | 2010-07-09 14:09:35 +0100 |
---|---|---|
committer | Seth Falcon <seth@opscode.com> | 2010-11-01 10:44:52 -0700 |
commit | 16302e94840a5682be7bbe29c343ec8b8bcacab6 (patch) | |
tree | 0993f1ae3d2146413dd0ab7655ce3efb753bd071 /chef-server-api/app | |
parent | f77f78afe9eb92ece5465efac7f1a5134373b7db (diff) | |
download | chef-16302e94840a5682be7bbe29c343ec8b8bcacab6.tar.gz |
Convert index_recipes to return *all* recipes
This changes the API somewhat; rather than just an array of recipes
(which is bust because recipes may only exist in certain versions of
cookbooks) you get a hash back: cookbook -> version -> recipes.
Change the only two places that use _recipes to DTRT
Diffstat (limited to 'chef-server-api/app')
-rw-r--r-- | chef-server-api/app/controllers/cookbooks.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/chef-server-api/app/controllers/cookbooks.rb b/chef-server-api/app/controllers/cookbooks.rb index 1c0490d744..dc3d18383e 100644 --- a/chef-server-api/app/controllers/cookbooks.rb +++ b/chef-server-api/app/controllers/cookbooks.rb @@ -58,13 +58,11 @@ class Cookbooks < Application end def index_recipes - all_cookbooks = Array(Chef::CookbookVersion.cdb_list_latest(true)) - all_cookbooks.map! do |cookbook| - cookbook.manifest["recipes"].map { |r| "#{cookbook.name}::#{File.basename(r['name'], ".rb")}" } + display Chef::CookbookVersion.cdb_list(true).inject({}) do |memo, f| + memo[f.name] ||= {} + memo[f.name][f.version] = f.recipe_filenames_by_name.keys + memo end - all_cookbooks.flatten! - all_cookbooks.sort! - display all_cookbooks end def show_versions |