Skip to content

Commit

Permalink
Add GCP support
Browse files Browse the repository at this point in the history
closes pulp#3424
  • Loading branch information
fao89 committed Jan 2, 2023
1 parent 3b49c1d commit bc6d5e8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/3424.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add GCP support
5 changes: 3 additions & 2 deletions pulpcore/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,11 @@
| Validator("DEFAULT_FILE_STORAGE", eq="pulpcore.app.models.storage.FileSystem")
| Validator("DEFAULT_FILE_STORAGE", eq="storages.backends.azure_storage.AzureStorage")
| Validator("DEFAULT_FILE_STORAGE", eq="storages.backends.s3boto3.S3Boto3Storage")
| Validator("DEFAULT_FILE_STORAGE", eq="storages.backends.gcloud.GoogleCloudStorage")
)
storage_validator.messages["combined"] = (
"'REDIRECT_TO_OBJECT_STORAGE=True' is only supported with the local file, S3 or Azure storage"
"backend configured in DEFAULT_FILE_STORAGE."
"'REDIRECT_TO_OBJECT_STORAGE=True' is only supported with the local file, S3, GCP or Azure"
"storage backend configured in DEFAULT_FILE_STORAGE."
)

cache_enabled_validator = Validator("CACHE_ENABLED", eq=True)
Expand Down
5 changes: 5 additions & 0 deletions pulpcore/app/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ def get_artifact_url(artifact, headers=None, http_method=None):
if headers and headers.get("Content-Type"):
parameters["content_type"] = headers.get("Content-Type")
url = artifact_file.storage.url(artifact_file.name, parameters=parameters)
elif settings.DEFAULT_FILE_STORAGE == "storages.backends.gcloud.GoogleCloudStorage":
parameters = {"response_disposition": content_disposition}
if headers and headers.get("Content-Type"):
parameters["content_type"] = headers.get("Content-Type")
url = artifact_file.storage.url(artifact_file.name, parameters=parameters)
else:
raise NotImplementedError(
f"The value settings.DEFAULT_FILE_STORAGE={settings.DEFAULT_FILE_STORAGE} "
Expand Down
6 changes: 6 additions & 0 deletions pulpcore/content/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,12 @@ async def _serve_content_artifact(self, content_artifact, headers, request):
parameters["content_type"] = headers.get("Content-Type")
url = URL(artifact_file.storage.url(artifact_name, parameters=parameters), encoded=True)
raise HTTPFound(url)
elif settings.DEFAULT_FILE_STORAGE == "storages.backends.gcloud.GoogleCloudStorage":
parameters = {"response_disposition": content_disposition}
if headers.get("Content-Type"):
parameters["content_type"] = headers.get("Content-Type")
url = URL(artifact_file.storage.url(artifact_name, parameters=parameters), encoded=True)
raise HTTPFound(url)
else:
raise NotImplementedError()

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
extras_require={
"sftp": ["django-storages[sftp]"],
"s3": ["django-storages[boto3]"],
"google": ["django-storages[google]>=1.13.2"],
"azure": ["django-storages[azure]>=1.12.2"],
"prometheus": ["django-prometheus"],
},
Expand Down

0 comments on commit bc6d5e8

Please sign in to comment.