diff options
Diffstat (limited to 'lib/chef_zero/endpoints/environment_recipes_endpoint.rb')
-rw-r--r-- | lib/chef_zero/endpoints/environment_recipes_endpoint.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/chef_zero/endpoints/environment_recipes_endpoint.rb b/lib/chef_zero/endpoints/environment_recipes_endpoint.rb new file mode 100644 index 0000000..0bbaa8b --- /dev/null +++ b/lib/chef_zero/endpoints/environment_recipes_endpoint.rb @@ -0,0 +1,22 @@ +require 'json' +require 'chef_zero/endpoints/cookbooks_base' + +module ChefZero + module Endpoints + # /environment/NAME/recipes + class EnvironmentRecipesEndpoint < CookbooksBase + def get(request) + environment = JSON.parse(get_data(request, request.rest_path[0..1]), :create_additions => false) + constraints = environment['cookbook_versions'] || {} + result = [] + filter_cookbooks(data['cookbooks'], constraints, 1) do |name, versions| + if versions.size > 0 + cookbook = JSON.parse(data['cookbooks'][name][versions[0]], :create_additions => false) + result += recipe_names(name, cookbook) + end + end + json_response(200, result.sort) + end + end + end +end |