summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb12
1 files changed, 10 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 dbc2f98..2e56a51 100644
--- a/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb
+++ b/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb
@@ -37,8 +37,11 @@ module ChefZero
solved = depsolve(request, desired_versions.keys, desired_versions, environment_constraints)
if !solved
if @last_missing_dep && !cookbook_names.include?(@last_missing_dep)
- return raise RestErrorResponse.new(412, "No such cookbook: #{@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
@@ -52,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]