Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding GCP support #1123

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions pulp_container/app/redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,21 @@ 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Azure/GCP

Copy link
Member

@mdellweg mdellweg Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have a pulpcore function for this now.

edit: Maybe it's not exactly compatible yet...

"""
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
Original file line number Diff line number Diff line change
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