@@ -26,10 +26,22 @@ API_ROOT = {{ api_root | repr }}
2626{% endfor %}
2727{% endif %}
2828
29- {% if s 3_test | default (false ) %}
30- MEDIA_ROOT: ""
31- S3_USE_SIGV4 = True
32- {% if test_storages_compat_layer is defined and test_storages_compat_layer %}
29+ {# =======================================
30+ Macros for legacy and new storage settings
31+ ========================================== -#}
32+
33+ {% - macro s 3_settings (legacy ) -%}
34+ {% - if legacy %}
35+ DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
36+ AWS_ACCESS_KEY_ID = "{{ minio_access_key }}"
37+ AWS_SECRET_ACCESS_KEY = "{{ minio_secret_key }}"
38+ AWS_S3_REGION_NAME = "eu-central-1"
39+ AWS_S3_ADDRESSING_STYLE = "path"
40+ AWS_S3_SIGNATURE_VERSION = "s3v4"
41+ AWS_STORAGE_BUCKET_NAME = "pulp3"
42+ AWS_S3_ENDPOINT_URL = "http://minio:9000"
43+ AWS_DEFAULT_ACL = "@none None"
44+ {% - else %}
3345STORAGES = {
3446 "default": {
3547 "BACKEND": "storages.backends.s3boto3.S3Boto3Storage",
@@ -48,34 +60,93 @@ STORAGES = {
4860 "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
4961 },
5062}
51- {% else %}
52- DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
53- AWS_ACCESS_KEY_ID = "{{ minio_access_key }}"
54- AWS_SECRET_ACCESS_KEY = "{{ minio_secret_key }}"
55- AWS_S3_REGION_NAME = "eu-central-1"
56- AWS_S3_ADDRESSING_STYLE = "path"
57- AWS_S3_SIGNATURE_VERSION = "s3v4"
58- AWS_STORAGE_BUCKET_NAME = "pulp3"
59- AWS_S3_ENDPOINT_URL = "http://minio:9000"
60- AWS_DEFAULT_ACL = "@none None"
61- {% endif %}
62- {% endif %}
63+ {% - endif %}
64+ {% - endmacro -%}
6365
64- {% if azure_test | default (false ) %}
66+ {% - macro azure_settings (legacy ) -%}
67+ {% - if legacy %}
6568DEFAULT_FILE_STORAGE = "storages.backends.azure_storage.AzureStorage"
66- MEDIA_ROOT = ""
6769AZURE_ACCOUNT_KEY = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
6870AZURE_ACCOUNT_NAME = "devstoreaccount1"
6971AZURE_CONTAINER = "pulp-test"
7072AZURE_LOCATION = "pulp3"
7173AZURE_OVERWRITE_FILES = True
7274AZURE_URL_EXPIRATION_SECS = 120
7375AZURE_CONNECTION_STRING = 'DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://ci-azurite:10000/devstoreaccount1;'
74- {% endif %}
76+ {% - else %}
77+ STORAGES = {
78+ "default": {
79+ "BACKEND": "storages.backends.azure_storage.AzureStorage",
80+ "OPTIONS": {
81+ "account_key": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==",
82+ "account_name": "devstoreaccount1",
83+ "location": "pulp3",
84+ "azure_container": "pulp-test",
85+ "overwrite_files": True,
86+ "expiration_secs": 120,
87+ "connection_string": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://ci-azurite:10000/devstoreaccount1;",
88+ },
89+ },
90+ "staticfiles": {
91+ "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
92+ },
93+ }
94+ {% - endif %}
95+ {% - endmacro -%}
7596
76- {% if gcp_test | default (false ) %}
97+ {% - macro gcp_settings (legacy ) -%}
98+ {% - if legacy %}
7799DEFAULT_FILE_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
78- MEDIA_ROOT = ""
79100GS_BUCKET_NAME = "gcppulp"
80101GS_CUSTOM_ENDPOINT = "http://ci-gcp:4443"
102+ {% - else %}
103+ STORAGES = {
104+ "default": {
105+ "BACKEND": "storages.backends.gcloud.GoogleCloudStorage",
106+ "OPTIONS": {
107+ "bucket_name": "gcppulp",
108+ "custom_endpoint": "http://ci-gcp:4443",
109+ },
110+ },
111+ "staticfiles": {
112+ "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
113+ },
114+ }
115+ {% - endif %}
116+ {% - endmacro -%}
117+
118+ {#- ==========================================
119+ Render according to test_storages_compat_layer
120+ ==============================================
121+
122+ Case 1) test_storages_compat_layer is unset
123+ - All storages render the legacy setting
124+ - Branches using pulpcore <3.70 must leave this key unset (use legacy)
125+
126+ Case 2) test_storages_compat_layer is True
127+ - To tests both work, only one setting uses the new storage setting
128+ - Branches using pulpcore >=3.70,<3.85 must set this key to True (test both)
129+
130+ Case 3) test_storages_compat_layer is False
131+ - All storages render the new setting
132+ - Branches using pulpcore >=3.85 must set this key to False (use new)
133+ -#}
134+
135+ {% if s 3_test | default (false ) or azure_test | default (false ) or gcp_test | default (false )%}
136+ MEDIA_ROOT=""
81137{% endif %}
138+ {% - if test_storages_compat_layer is not defined -%}
139+ {% - if s 3_test | default (false ) -%} {{ s3_settings(legacy=True) }}{% - endif -%}
140+ {% - if azure_test | default (false ) -%} {{ azure_settings(legacy=True) }}{% - endif -%}
141+ {% - if gcp_test | default (false ) -%} {{ gcp_settings(legacy=True) }}{% - endif -%}
142+ {% - else -%}
143+ {% - if test_storages_compat_layer is true -%}
144+ {% - if s 3_test | default (false ) -%} {{ s3_settings(legacy=False) }}{% - endif -%}
145+ {% - if azure_test | default (false ) -%} {{ azure_settings(legacy=True) }}{% - endif -%}
146+ {% - if gcp_test | default (false ) -%} {{ gcp_settings(legacy=True) }}{% - endif -%}
147+ {% - elif test_storages_compat_layer is false -%}
148+ {% - if s 3_test | default (false ) -%} {{ s3_settings(legacy=False) }}{% - endif -%}
149+ {% - if azure_test | default (false ) -%} {{ azure_settings(legacy=False) }}{% - endif -%}
150+ {% - if gcp_test | default (false ) -%} {{ gcp_settings(legacy=False) }}{% - endif -%}
151+ {% - endif -%}
152+ {% - endif -%}
0 commit comments