Merge pull request #2869 from coreos-inc/joseph.schorr/QS-2/cloudfront

CloudFront redirect support
This commit is contained in:
josephschorr 2017-09-29 12:08:50 -04:00 committed by GitHub
commit 82e09d6f16
27 changed files with 388 additions and 29 deletions

View file

@ -6,6 +6,7 @@ from cnr.models.channel_base import ChannelBase
from cnr.models.db_base import CnrDB
from cnr.models.package_base import PackageBase, manifest_media_type
from flask import request
from app import storage
from endpoints.appr.models_oci import model
@ -36,7 +37,7 @@ class Blob(BlobBase):
locations = model.get_blob_locations(digest)
if not locations:
raise_package_not_found(package_name, digest)
return storage.get_direct_download_url(locations, blobpath)
return storage.get_direct_download_url(locations, blobpath, request.remote_addr)
class Channel(ChannelBase):

View file

@ -132,7 +132,7 @@ def get_image_layer(namespace, repository, image_id, headers):
abort(404, 'Image %(image_id)s not found', issue='unknown-image', image_id=image_id)
try:
logger.debug('Looking up the direct download URL for path: %s', path)
direct_download_url = store.get_direct_download_url(locations, path)
direct_download_url = store.get_direct_download_url(locations, path, request.remote_addr)
if direct_download_url:
logger.debug('Returning direct download URL')
resp = redirect(direct_download_url)

View file

@ -83,7 +83,7 @@ def download_blob(namespace_name, repo_name, digest):
# Short-circuit by redirecting if the storage supports it.
logger.debug('Looking up the direct download URL for path: %s', path)
direct_download_url = storage.get_direct_download_url(blob.locations, path)
direct_download_url = storage.get_direct_download_url(blob.locations, path, request.remote_addr)
if direct_download_url:
logger.debug('Returning direct download URL')
resp = redirect(direct_download_url)