Skip to content

Commit 624a256

Browse files
committed
fix: variables
1 parent 73dd5a0 commit 624a256

File tree

3 files changed

+23
-77
lines changed

3 files changed

+23
-77
lines changed

.deploy/service.json

+2-8
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,12 @@
1919
"APP_VERSION": "REPLACE_IN_PIPELINE",
2020
"DJANGO_SETTINGS_MODULE": "REPLACE_IN_PIPELINE",
2121
"DEBUG": "REPLACE_IN_PIPELINE",
22+
"ENV": "REPLACE_IN_PIPELINE",
2223
"SERVICE_PROTOCOL": "REPLACE_IN_PIPELINE",
2324
"SERVICE_PORT": "REPLACE_IN_PIPELINE",
2425
"MAIL_ENABLED": "REPLACE_IN_PIPELINE",
25-
"STATIC_ROOT": "REPLACE_IN_PIPELINE",
2626
"STATIC_URL": "REPLACE_IN_PIPELINE",
27-
"AWS_STORAGE_BUCKET_NAME": "REPLACE_IN_PIPELINE",
28-
"AWS_S3_ADDRESSING_STYLE": "${AWS_S3_ADDRESSING_STYLE}",
29-
"AWS_S3_REGION_NAME": "${AWS_S3_REGION_NAME}",
30-
"AWS_DEFAULT_ACL": "${AWS_DEFAULT_ACL}",
31-
"AWS_LOCATION": "${AWS_LOCATION}",
32-
"AWS_S3_CUSTOM_DOMAIN": "${AWS_S3_CUSTOM_DOMAIN}",
33-
"STATICFILES_DIRS": "${STATICFILES_DIRS}"
27+
"AWS_STORAGE_BUCKET_NAME": "REPLACE_IN_PIPELINE"
3428
}
3529
}
3630
]

api/urls.py

+1-46
Original file line numberDiff line numberDiff line change
@@ -56,52 +56,7 @@ def get_health_check(self, request):
5656
details=[
5757
HealthCheck.Detail(
5858
name="settings_secrets_keys",
59-
description=",".join(list(settings.secrets.keys())),
60-
health="healthy",
61-
),
62-
HealthCheck.Detail(
63-
name="STATIC_ROOT",
64-
description=str(settings.STATIC_ROOT),
65-
health="healthy",
66-
),
67-
HealthCheck.Detail(
68-
name="STATIC_URL",
69-
description=str(settings.STATIC_URL),
70-
health="healthy",
71-
),
72-
HealthCheck.Detail(
73-
name="AWS_STORAGE_BUCKET_NAME",
74-
description=str(settings.AWS_STORAGE_BUCKET_NAME),
75-
health="healthy",
76-
),
77-
HealthCheck.Detail(
78-
name="AWS_S3_CUSTOM_DOMAIN",
79-
description=str(settings.AWS_S3_CUSTOM_DOMAIN),
80-
health="healthy",
81-
),
82-
HealthCheck.Detail(
83-
name="AWS_LOCATION",
84-
description=str(settings.AWS_LOCATION),
85-
health="healthy",
86-
),
87-
HealthCheck.Detail(
88-
name="AWS_DEFAULT_ACL",
89-
description=str(settings.AWS_DEFAULT_ACL),
90-
health="healthy",
91-
),
92-
HealthCheck.Detail(
93-
name="AWS_S3_ADDRESSING_STYLE",
94-
description=str(settings.AWS_S3_ADDRESSING_STYLE),
95-
health="healthy",
96-
),
97-
HealthCheck.Detail(
98-
name="AWS_S3_REGION_NAME",
99-
description=str(settings.AWS_S3_REGION_NAME),
100-
health="healthy",
101-
),
102-
HealthCheck.Detail(
103-
name="STATICFILES_DIRS",
104-
description=str(settings.STATICFILES_DIRS),
59+
description=",".join(list(settings.SECRETS.keys())),
10560
health="healthy",
10661
),
10762
],

settings.py

+20-23
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from pathlib import Path
1818

1919

20-
def set_up_settings(service_name: str):
20+
def set_up_settings(service_base_dir: Path, service_name: str):
2121
"""Set up the settings for the service.
2222
2323
*This needs to be called before importing the CFL settings!*
@@ -27,12 +27,13 @@ def set_up_settings(service_name: str):
2727
from codeforlife import set_up_settings
2828
2929
# Must set up settings before importing them!
30-
secrets = set_up_settings("example")
30+
SECRETS = set_up_settings("example")
3131
3232
from codeforlife.settings import *
3333
```
3434
3535
Args:
36+
service_base_dir: The base directory of the service.
3637
service_name: The name of the current service.
3738
3839
Returns:
@@ -59,6 +60,7 @@ def set_up_settings(service_name: str):
5960
"You must set up the CFL settings before importing them."
6061
)
6162

63+
os.environ["SERVICE_BASE_DIR"] = str(service_base_dir)
6264
os.environ["SERVICE_NAME"] = service_name
6365

6466
os.environ.setdefault("ENV", "local")
@@ -107,7 +109,7 @@ def set_up_settings(service_name: str):
107109
# Build paths inside the project like this: BASE_DIR / 'subdir'.
108110
BASE_DIR = Path(__file__).resolve().parent
109111

110-
secrets = set_up_settings(service_name="contributor")
112+
SECRETS = set_up_settings(BASE_DIR, service_name="contributor")
111113

112114
# pylint: disable-next=wildcard-import,unused-wildcard-import,wrong-import-position
113115
from codeforlife.settings import *
@@ -147,31 +149,26 @@ def set_up_settings(service_name: str):
147149
# https://docs.djangoproject.com/en/3.2/howto/static-files/
148150

149151
# TODO: move to cfl package and create helper functions.
150-
# STATIC_ROOT = get_static_root(BASE_DIR)
151-
STATIC_ROOT = os.getenv("STATIC_ROOT", BASE_DIR / "static")
152+
STATIC_ROOT = Path(os.environ["SERVICE_BASE_DIR"]) / "static"
152153
STATIC_URL = os.getenv("STATIC_URL", "/static/")
153-
STATICFILES_DIRS = (
154-
os.environ["STATICFILES_DIRS"].split(",")
155-
if os.getenv("STATICFILES_DIRS")
156-
else []
157-
)
154+
158155

159156
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
160157
AWS_STORAGE_BUCKET_NAME = os.getenv("AWS_STORAGE_BUCKET_NAME")
161158

162-
AWS_S3_CUSTOM_DOMAIN = os.getenv("AWS_S3_CUSTOM_DOMAIN")
163-
if AWS_S3_CUSTOM_DOMAIN == "":
164-
AWS_S3_CUSTOM_DOMAIN = None
165-
AWS_LOCATION = os.getenv("AWS_LOCATION", "")
166-
AWS_DEFAULT_ACL = os.getenv("AWS_DEFAULT_ACL")
167-
if AWS_DEFAULT_ACL == "":
168-
AWS_DEFAULT_ACL = None
169-
AWS_S3_ADDRESSING_STYLE = os.getenv("AWS_S3_ADDRESSING_STYLE")
170-
if AWS_S3_ADDRESSING_STYLE == "":
171-
AWS_S3_ADDRESSING_STYLE = None
172-
AWS_S3_REGION_NAME = os.getenv("AWS_S3_REGION_NAME")
173-
if AWS_S3_REGION_NAME == "":
174-
AWS_S3_REGION_NAME = None
159+
# AWS_S3_CUSTOM_DOMAIN = os.getenv("AWS_S3_CUSTOM_DOMAIN")
160+
# if AWS_S3_CUSTOM_DOMAIN == "":
161+
# AWS_S3_CUSTOM_DOMAIN = None
162+
# AWS_LOCATION = os.getenv("AWS_LOCATION", "")
163+
# AWS_DEFAULT_ACL = os.getenv("AWS_DEFAULT_ACL")
164+
# if AWS_DEFAULT_ACL == "":
165+
# AWS_DEFAULT_ACL = None
166+
# AWS_S3_ADDRESSING_STYLE = os.getenv("AWS_S3_ADDRESSING_STYLE")
167+
# if AWS_S3_ADDRESSING_STYLE == "":
168+
# AWS_S3_ADDRESSING_STYLE = None
169+
# AWS_S3_REGION_NAME = os.getenv("AWS_S3_REGION_NAME")
170+
# if AWS_S3_REGION_NAME == "":
171+
# AWS_S3_REGION_NAME = None
175172
if AWS_STORAGE_BUCKET_NAME:
176173
if "storages" not in INSTALLED_APPS:
177174
INSTALLED_APPS.append("storages")

0 commit comments

Comments
 (0)