diff options
author | John Keiser <john@johnkeiser.com> | 2013-10-29 07:55:45 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2013-10-29 07:55:45 -0700 |
commit | adf232fad983980ba70825989c99682c0ff07975 (patch) | |
tree | b70a020abeeb4ae72cf6c99e9e46c03b532e52ab /lib/chef_zero/endpoints | |
parent | 2ca63cf97647f587f6bc705657505b56962380bb (diff) | |
parent | 056b975dd45f94cc690e3c0e8bc6780623c481ce (diff) | |
download | chef-zero-adf232fad983980ba70825989c99682c0ff07975.tar.gz |
Merge pull request #40 from opscode/lcg/better-depsolver-error
improve depsolver error message
Diffstat (limited to 'lib/chef_zero/endpoints')
-rw-r--r-- | lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb b/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb index efd21a4..2e56a51 100644 --- a/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +++ b/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb @@ -6,6 +6,7 @@ module ChefZero module Endpoints # /environments/NAME/cookbook_versions class EnvironmentCookbookVersionsEndpoint < RestBase + def post(request) cookbook_names = list_data(request, ['cookbooks']) @@ -35,7 +36,14 @@ module ChefZero # Depsolve! solved = depsolve(request, desired_versions.keys, desired_versions, environment_constraints) if !solved - return raise RestErrorResponse.new(412, "Unsolvable versions!") + if @last_missing_dep && !cookbook_names.include?(@last_missing_dep) + return raise RestErrorResponse.new(412, "No such cookbook: #{@last_missing_dep}") + elsif @last_constraint_failure + return raise RestErrorResponse.new(412, "Could not satisfy version constraints for: #{@last_constraint_failure}") + else + + return raise RestErrorResponse.new(412, "Unsolvable versions!") + end end result = {} @@ -47,7 +55,12 @@ module ChefZero end def depsolve(request, unsolved, desired_versions, environment_constraints) - return nil if desired_versions.values.any? { |versions| versions.empty? } + desired_versions.each do |cb, ver| + if ver.empty? + @last_constraint_failure = cb + return nil + end + end # If everything is already solve_for = unsolved[0] @@ -72,6 +85,7 @@ module ChefZero new_unsolved = new_unsolved + [dep_name] # If the dep is missing, we will try other versions of the cookbook that might not have the bad dep. if !exists_data_dir?(request, ['cookbooks', dep_name]) + @last_missing_dep = dep_name.to_s dep_not_found = true break end |