Skip to content

Commit c34c168

Browse files
committed
Update CI settings to partially use new storage settings
1 parent de39512 commit c34c168

File tree

4 files changed

+42
-21
lines changed

4 files changed

+42
-21
lines changed

.ci/ansible/settings.py.j2

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,30 @@ API_ROOT = {{ api_root | repr }}
2727
{% endif %}
2828

2929
{% if s3_test | default(false) %}
30-
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
31-
MEDIA_ROOT = ""
32-
AWS_ACCESS_KEY_ID = "{{ minio_access_key }}"
33-
AWS_SECRET_ACCESS_KEY = "{{ minio_secret_key }}"
34-
AWS_S3_REGION_NAME = "eu-central-1"
35-
AWS_S3_ADDRESSING_STYLE = "path"
30+
MEDIA_ROOT: ""
3631
S3_USE_SIGV4 = True
37-
AWS_S3_SIGNATURE_VERSION = "s3v4"
38-
AWS_STORAGE_BUCKET_NAME = "pulp3"
39-
AWS_S3_ENDPOINT_URL = "http://minio:9000"
40-
AWS_DEFAULT_ACL = "@none None"
32+
STORAGES = {
33+
"default": {
34+
"BACKEND": "storages.backends.s3boto3.S3Boto3Storage",
35+
"OPTIONS": {
36+
"access_key": "{{ minio_access_key }}",
37+
"secret_key": "{{ minio_secret_key }}",
38+
"region_name": "eu-central-1",
39+
"addressing_style": "path",
40+
"signature_version": "s3v4",
41+
"bucket_name": "pulp3",
42+
"endpoint_url": "http://minio:9000",
43+
"default_acl": "@none None",
44+
},
45+
},
46+
"staticfiles": {
47+
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
48+
},
49+
}
4150
{% endif %}
4251

52+
# This is using DEFAULT_FILE_STORAGE to test both usages.
53+
# Remove when DEFAULT_FILE_STORAGE is completely removed.
4354
{% if azure_test | default(false) %}
4455
DEFAULT_FILE_STORAGE = "storages.backends.azure_storage.AzureStorage"
4556
MEDIA_ROOT = ""

pulpcore/app/serializers/domain.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ def to_representation(self, instance):
4242
# Should I convert back the saved settings to their Setting names for to_representation?
4343
if getattr(self.context.get("domain", None), "name", None) == "default":
4444
for setting_name, field in self.SETTING_MAPPING.items():
45-
if value := getattr(settings, setting_name.upper(), None):
45+
value = getattr(settings, setting_name, None) or settings.STORAGES["default"].get(
46+
"OPTIONS", {}
47+
).get(field)
48+
if value:
4649
instance[field] = value
4750
return super().to_representation(instance)
4851

pulpcore/pytest_plugin.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,13 +603,13 @@ def _settings_factory(storage_class=None, storage_settings=None):
603603
keys = dict()
604604
keys["pulpcore.app.models.storage.FileSystem"] = ["MEDIA_ROOT", "MEDIA_URL"]
605605
keys["storages.backends.s3boto3.S3Boto3Storage"] = [
606-
"AWS_ACCESS_KEY_ID",
607-
"AWS_SECRET_ACCESS_KEY",
608-
"AWS_S3_ENDPOINT_URL",
609-
"AWS_S3_ADDRESSING_STYLE",
610-
"AWS_S3_SIGNATURE_VERSION",
611-
"AWS_S3_REGION_NAME",
612-
"AWS_STORAGE_BUCKET_NAME",
606+
"access_key",
607+
"secret_key",
608+
"endpoint_url",
609+
"addressing_style",
610+
"signature_version",
611+
"region_name",
612+
"bucket_name",
613613
]
614614
keys["storages.backends.azure_storage.AzureStorage"] = [
615615
"AZURE_ACCOUNT_NAME",
@@ -622,8 +622,16 @@ def _settings_factory(storage_class=None, storage_settings=None):
622622
]
623623
settings = storage_settings or dict()
624624
backend = storage_class or pulp_settings.STORAGES["default"]["BACKEND"]
625-
for key in keys[backend]:
626-
if key not in settings:
625+
not_defined_settings = (k for k in keys[backend] if k not in settings)
626+
# The CI configures s3 with STORAGES and Azure with legacy
627+
# Move all to STORAGES structure on DEFAULT_FILE_STORAGE removal
628+
if backend == "storages.backends.s3boto3.S3Boto3Storage":
629+
storages_dict = getattr(pulp_settings, "STORAGES", {})
630+
storage_options = storages_dict.get("default", {}).get("OPTIONS", {})
631+
for key in not_defined_settings:
632+
settings[key] = storage_options.get(key)
633+
else:
634+
for key in not_defined_settings:
627635
settings[key] = getattr(pulp_settings, key, None)
628636
return backend, settings
629637

pulpcore/tests/functional/api/test_crd_artifacts.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import pytest
88

99

10-
1110
@pytest.fixture
1211
def pulpcore_random_file(tmp_path):
1312
name = tmp_path / str(uuid.uuid4())

0 commit comments

Comments
 (0)