summaryrefslogtreecommitdiff
path: root/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb')
-rw-r--r--lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb42
1 files changed, 20 insertions, 22 deletions
diff --git a/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb b/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb
index e586e94..9f7b973 100644
--- a/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb
+++ b/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb
@@ -10,7 +10,7 @@ module ChefZero
# GET /organizations/ORG/cookbook_artifacts/NAME/IDENTIFIER
def get(request)
cookbook_data = normalize(request, get_data(request))
- return json_response(200, cookbook_data)
+ json_response(200, cookbook_data)
end
# PUT /organizations/ORG/cookbook_artifacts/COOKBOOK/IDENTIFIER
@@ -22,34 +22,32 @@ module ChefZero
cb_data = normalize(request, request.body)
set_data(request, nil, to_json(cb_data), :create_dir, :create)
- return already_json_response(201, request.body)
+ already_json_response(201, request.body)
end
# DELETE /organizations/ORG/cookbook_artifacts/COOKBOOK/IDENTIFIER
def delete(request)
- begin
- doomed_cookbook_json = get_data(request)
- identified_cookbook_data = normalize(request, doomed_cookbook_json)
- delete_data(request)
+ doomed_cookbook_json = get_data(request)
+ identified_cookbook_data = normalize(request, doomed_cookbook_json)
+ delete_data(request)
- # go through the recipes and delete stuff in the file store.
- hoover_unused_checksums(get_checksums(doomed_cookbook_json), request)
+ # go through the recipes and delete stuff in the file store.
+ hoover_unused_checksums(get_checksums(doomed_cookbook_json), request)
- # if this was the last revision, delete the directory so future requests will 404, instead of
- # returning 200 with an empty list.
- # Last one out turns out the lights: delete /organizations/ORG/cookbooks/COOKBOOK if it no longer has versions
- cookbook_path = request.rest_path[0..3]
- if exists_data_dir?(request, cookbook_path) && list_data(request, cookbook_path).size == 0
- delete_data_dir(request, cookbook_path)
- end
+ # if this was the last revision, delete the directory so future requests will 404, instead of
+ # returning 200 with an empty list.
+ # Last one out turns out the lights: delete /organizations/ORG/cookbooks/COOKBOOK if it no longer has versions
+ cookbook_path = request.rest_path[0..3]
+ if exists_data_dir?(request, cookbook_path) && list_data(request, cookbook_path).size == 0
+ delete_data_dir(request, cookbook_path)
+ end
- json_response(200, identified_cookbook_data)
- rescue RestErrorResponse => ex
- if ex.response_code == 404
- error(404, "not_found")
- else
- raise
- end
+ json_response(200, identified_cookbook_data)
+ rescue RestErrorResponse => ex
+ if ex.response_code == 404
+ error(404, "not_found")
+ else
+ raise
end
end