Skip to content

Commit

Permalink
Adding GCP support
Browse files Browse the repository at this point in the history
  • Loading branch information
fao89 committed Oct 28, 2022
1 parent 3a98395 commit 7d91c5e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pulp_container/app/redirects.py
Expand Up @@ -132,3 +132,20 @@ def redirect_to_object_storage(self, artifact, return_media_type):
}
content_url = artifact.file.storage.url(artifact.file.name, parameters=parameters)
return redirect(content_url)

class GCloudStorageRedirects(S3StorageRedirects):
"""
A class that implements methods for the direct retrieval of manifest objects.
"""

def redirect_to_object_storage(self, artifact, return_media_type):
"""
Redirect to the passed artifact's file stored in the Azure storage.
"""
filename = f"sha256:{artifact.sha256}"
parameters = {
"content_type": return_media_type,
"response_disposition": f"attachment;filename={filename}",
}
content_url = artifact.file.storage.url(artifact.file.name, parameters=parameters)
return redirect(content_url)
3 changes: 3 additions & 0 deletions pulp_container/app/registry_api.py
Expand Up @@ -65,6 +65,7 @@
FileStorageRedirects,
S3StorageRedirects,
AzureStorageRedirects,
GCloudStorageRedirects,
)
from pulp_container.app.token_verification import (
RegistryAuthentication,
Expand Down Expand Up @@ -794,6 +795,8 @@ def __init__(self, *args, **kwargs):
self.redirects_class = S3StorageRedirects
elif settings.DEFAULT_FILE_STORAGE == "storages.backends.azure_storage.AzureStorage":
self.redirects_class = AzureStorageRedirects
elif settings.DEFAULT_FILE_STORAGE == "storages.backends.gcloud.GoogleCloudStorage":
self.redirects_class = GCloudStorageRedirects
else:
raise NotImplementedError()

Expand Down

0 comments on commit 7d91c5e

Please sign in to comment.