Skip to content

Commit

Permalink
feat(helm-local_settings): Add option to add local_settings.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kiblik committed Aug 23, 2024
1 parent 0a0d101 commit cea7b4e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/content/en/getting_started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ When you deploy DefectDojo in a **Kubernetes** cluster, you can set environment

An example can be found in [`template_env`](https://github.com/DefectDojo/django-DefectDojo/blob/master/dojo/settings/template-env).

### local_settings.py (not with Kubernetes)
### local_settings.py

`local_settings.py` can contain more complex customizations such as adding MIDDLEWARE or INSTALLED_APP entries.
This file is processed *after* settings.dist.py is processed, so you can modify settings delivered by DefectDojo out of the box.
Expand All @@ -34,6 +34,8 @@ An example can be found in [`dojo/settings/template-local_settings`](https://git

In Docker Compose release mode, files in `docker/extra_settings/` (relative to the file `docker-compose.yml`) will be copied into `dojo/settings/` in the docker container on startup.

`local_settings.py` can be used in Kubernetes as well. Variable `localSettingsPy` will stored as ConfigMap and mounted to responsible location of container.

## Configuration in the UI

Users with the superuser status can configure more options via the UI under `Configuration` / `System Settings`.
15 changes: 15 additions & 0 deletions helm/defectdojo/templates/configmap-local-settings-py.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.localSettingsPy }}
{{- $fullName := include "defectdojo.fullname" . -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $fullName }}-localSettingsPy
labels:
app.kubernetes.io/name: {{ include "defectdojo.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
data:
file:
{{ toYaml .Values.localSettingsPy | indent 4 }}
{{- end }}
12 changes: 12 additions & 0 deletions helm/defectdojo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -496,3 +496,15 @@ extraConfigs: {}
# configMapKeyRef:
# name: my-other-postgres-configmap
# key: cluster_endpoint

# To add code snippet which would extend setting functionality, you might add it here
# It will be stored as ConfigMap and mounted `dojo/settings/template-local_settings`.
# For more see: https://documentation.defectdojo.com/getting_started/configuration/
# For example:
# localSettingsPy: |
# INSTALLED_APPS += (
# 'debug_toolbar',
# )
# MIDDLEWARE = [
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
# ] + MIDDLEWARE

0 comments on commit cea7b4e

Please sign in to comment.