Skip to content

Commit

Permalink
Feature/add local settings (#242)
Browse files Browse the repository at this point in the history
* Add local setting files

Allows us to simplify some settings such as
ALLOWED_HOSTS and QUICKSIGHT_DOMAINS

* Read DEBUG from env var

* Bump chart version
  • Loading branch information
michaeljcollinsuk authored Aug 15, 2024
1 parent 94bd4ca commit 44eb737
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions ap/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@


# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = os.environ.get("DEBUG", True)

# Application definition

Expand Down Expand Up @@ -213,7 +213,10 @@

# set this before adding the IP address below
# TODO We may be able to set this in terraform instead, we should check this
QUICKSIGHT_DOMAINS = [f"https://{host}" for host in ALLOWED_HOSTS] or ["http://localhost:8000"]
QUICKSIGHT_DOMAINS = []
for host in ALLOWED_HOSTS:
prefix = "*" if host.startswith(".") else ""
QUICKSIGHT_DOMAINS.append(f"https://{prefix}{host}")

try:
ALLOWED_HOSTS.append(gethostbyname(gethostname()))
Expand Down
9 changes: 9 additions & 0 deletions ap/settings/local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .common import * # noqa

DEBUG = True

ALLOWED_HOSTS = [".localhost", "127.0.0.1"]

QUICKSIGHT_DOMAINS = ["http://localhost:8000"]

ENV = "local"
4 changes: 2 additions & 2 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ apiVersion: v2
name: analytical-platform-ui
description: Analytical Platform UI
type: application
version: 0.1.4
appVersion: 0.1.4
version: 0.1.5
appVersion: 0.1.5
icon: https://upload.wikimedia.org/wikipedia/en/thumb/4/4a/Ministry_of_Justice_logo_%28United_Kingdom%29.svg/611px-Ministry_of_Justice_logo_%28United_Kingdom%29.svg.png
maintainers:
- name: moj-data-platform-robot
Expand Down
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ app:
- name: DJANGO_SETTINGS_MODULE
value: ap.settings
- name: ALLOWED_HOSTS
value: "*.analytical-platform.service.justice.gov.uk"
value: ".analytical-platform.service.justice.gov.uk"
- name: DB_USER
valueFrom:
secretKeyRef:
Expand Down

0 comments on commit 44eb737

Please sign in to comment.