v2/blob: s/make_response/Response()
This commit is contained in:
parent
35579093ca
commit
16b451437f
2 changed files with 65 additions and 61 deletions
|
@ -2,7 +2,7 @@ import logging
|
|||
|
||||
from functools import wraps
|
||||
|
||||
from flask import make_response, request, url_for
|
||||
from flask import request, url_for, Response
|
||||
|
||||
import features
|
||||
|
||||
|
@ -51,10 +51,11 @@ def fetch_manifest_by_tagname(namespace_name, repo_name, tag_name):
|
|||
track_and_log('pull_repo', repo, analytics_name='pull_repo_100x', analytics_sample=0.01)
|
||||
metric_queue.repository_pull.Inc(labelvalues=[namespace_name, repo_name, 'v2'])
|
||||
|
||||
response = make_response(manifest.bytes, 200)
|
||||
response.headers['Content-Type'] = manifest.content_type
|
||||
response.headers['Docker-Content-Digest'] = manifest.digest
|
||||
return response
|
||||
return Response(
|
||||
manifest.bytes,
|
||||
status=200,
|
||||
headers={'Content-Type': manifest.content_type, 'Docker-Content-Digest': manifest.digest},
|
||||
)
|
||||
|
||||
|
||||
@v2_bp.route(MANIFEST_DIGEST_ROUTE, methods=['GET'])
|
||||
|
@ -73,10 +74,8 @@ def fetch_manifest_by_digest(namespace_name, repo_name, manifest_ref):
|
|||
track_and_log('pull_repo', repo)
|
||||
metric_queue.repository_pull.Inc(labelvalues=[namespace_name, repo_name, 'v2'])
|
||||
|
||||
response = make_response(manifest.json, 200)
|
||||
response.headers['Content-Type'] = manifest.content_type
|
||||
response.headers['Docker-Content-Digest'] = manifest.digest
|
||||
return response
|
||||
return Response(manifest.json, status=200, headers={'Content-Type': manifest.content_type,
|
||||
'Docker-Content-Digest': manifest.digest})
|
||||
|
||||
|
||||
def _reject_manifest2_schema2(func):
|
||||
|
@ -190,12 +189,16 @@ def _write_manifest(namespace_name, repo_name, manifest):
|
|||
spawn_notification(repo, 'repo_push', {'updated_tags': [manifest.tag]})
|
||||
metric_queue.repository_push.Inc(labelvalues=[namespace_name, repo_name, 'v2'])
|
||||
|
||||
response = make_response('OK', 202)
|
||||
response.headers['Docker-Content-Digest'] = manifest.digest
|
||||
response.headers['Location'] = url_for('v2.fetch_manifest_by_digest',
|
||||
repository='%s/%s' % (namespace_name, repo_name),
|
||||
manifest_ref=manifest.digest)
|
||||
return response
|
||||
return Response(
|
||||
'OK',
|
||||
status=202,
|
||||
headers={
|
||||
'Docker-Content-Digest': manifest.digest,
|
||||
'Location': url_for('v2.fetch_manifest_by_digest',
|
||||
repository='%s/%s' % (namespace_name, repo_name),
|
||||
manifest_ref=manifest.digest),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@v2_bp.route(MANIFEST_DIGEST_ROUTE, methods=['DELETE'])
|
||||
|
@ -223,7 +226,7 @@ def delete_manifest_by_digest(namespace_name, repo_name, digest):
|
|||
|
||||
track_and_log('delete_tag', tag.repository, tag=tag.name, digest=digest)
|
||||
|
||||
return make_response('', 202)
|
||||
return Response(status=202)
|
||||
|
||||
|
||||
def _generate_and_store_manifest(namespace_name, repo_name, tag_name):
|
||||
|
|
Reference in a new issue