From bf5c7894774df8e8763c182c17f456fcf4cf2f44 Mon Sep 17 00:00:00 2001 From: Pedro Brochado Date: Fri, 10 Jan 2025 16:43:51 -0300 Subject: [PATCH] Replace deprecated DEFAULT_FILE_STORAGE with STORAGES --- pulp_container/app/registry.py | 2 +- pulp_container/app/registry_api.py | 9 ++++++--- pulp_container/app/tasks/sign.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pulp_container/app/registry.py b/pulp_container/app/registry.py index be6b1cced..f60e216e4 100644 --- a/pulp_container/app/registry.py +++ b/pulp_container/app/registry.py @@ -83,7 +83,7 @@ async def _dispatch(artifact, headers): full_headers["Docker-Content-Digest"] = headers["Docker-Content-Digest"] full_headers["Docker-Distribution-API-Version"] = "registry/2.0" - if settings.DEFAULT_FILE_STORAGE == "pulpcore.app.models.storage.FileSystem": + if settings.STORAGES["default"]["BACKEND"] == "pulpcore.app.models.storage.FileSystem": file = artifact.file path = os.path.join(settings.MEDIA_ROOT, file.name) if not os.path.exists(path): diff --git a/pulp_container/app/registry_api.py b/pulp_container/app/registry_api.py index 72e416ab3..f262fd58c 100644 --- a/pulp_container/app/registry_api.py +++ b/pulp_container/app/registry_api.py @@ -966,13 +966,16 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if ( - settings.DEFAULT_FILE_STORAGE == "pulpcore.app.models.storage.FileSystem" + settings.STORAGES["default"]["BACKEND"] == "pulpcore.app.models.storage.FileSystem" or not settings.REDIRECT_TO_OBJECT_STORAGE ): self.redirects_class = FileStorageRedirects - elif settings.DEFAULT_FILE_STORAGE == "storages.backends.s3boto3.S3Boto3Storage": + elif settings.STORAGES["default"]["BACKEND"] == "storages.backends.s3boto3.S3Boto3Storage": self.redirects_class = S3StorageRedirects - elif settings.DEFAULT_FILE_STORAGE == "storages.backends.azure_storage.AzureStorage": + elif ( + settings.STORAGES["default"]["BACKEND"] + == "storages.backends.azure_storage.AzureStorage" + ): self.redirects_class = AzureStorageRedirects else: raise NotImplementedError() diff --git a/pulp_container/app/tasks/sign.py b/pulp_container/app/tasks/sign.py index 958c80b8b..c87319536 100644 --- a/pulp_container/app/tasks/sign.py +++ b/pulp_container/app/tasks/sign.py @@ -106,7 +106,7 @@ async def create_signature(manifest, reference, signing_service): if not manifest.data: # TODO: BACKWARD COMPATIBILITY - remove after fully migrating to artifactless manifest artifact = await manifest._artifacts.aget() - if settings.DEFAULT_FILE_STORAGE != "pulpcore.app.models.storage.FileSystem": + if settings.STORAGES["default"]["BACKEND"] != "pulpcore.app.models.storage.FileSystem": async with tempfile.NamedTemporaryFile(dir=".", mode="wb", delete=False) as tf: await tf.write(await sync_to_async(artifact.file.read)()) await tf.flush()