From 99bfc3ca7a6cb63ce44a36fdc42030ab80ad523a Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org> Date: Wed, 22 Nov 2023 16:35:23 +0100 Subject: [PATCH] settings.production: Allow extra azure configuration Currently, the writing in the azure objstorage adds extra headers to the blobs. Which prevents the correct reading of those blobs when checking the tarballs. According to the documentation, this option opening should allow to configure more appropriately. Refs. swh/infra/sysadm-environment#5129 --- swh/deposit/settings/production.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/swh/deposit/settings/production.py b/swh/deposit/settings/production.py index 81e6b705..61b5ee60 100644 --- a/swh/deposit/settings/production.py +++ b/swh/deposit/settings/production.py @@ -123,15 +123,27 @@ if cfg_azure: f"Production: invalid configuration; missing {key} config entry." ) + # Default options + options = dict( + azure_container=cfg_azure["container_name"], + connection_string=cfg_azure["connection_string"], + ) + + # Which may be enhanced with some extra options, lookup "object_parameters" in + # https://django-storages.readthedocs.io/en/latest/backends/azure.html + object_parameters = {} + for optional_config_key in ["content_type", "content_disposition"]: + if optional_config_key in cfg_azure: + object_parameters[optional_config_key] = cfg_azure[optional_config_key] + + options.update(dict(object_parameters=object_parameters)) + STORAGES = { "staticfiles": { "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage" }, "default": { "BACKEND": "storages.backends.azure_storage.AzureStorage", - "OPTIONS": { - "azure_container": cfg_azure["container_name"], - "connection_string": cfg_azure["connection_string"], - }, + "OPTIONS": options, }, } -- GitLab