enable django checks

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt 2024-01-11 17:00:17 +01:00
parent 4ecb571291
commit cb7cd11778
No known key found for this signature in database
GPG Key ID: 9C3FA22FABF1AA8D
2 changed files with 13 additions and 3 deletions

View File

@ -6,7 +6,7 @@ from django_tenants.utils import get_public_schema_name
from authentik.blueprints.apps import ManagedAppConfig
def reconcile_default_tenant(*args, using=DEFAULT_DB_ALIAS, **kwargs):
def ensure_default_tenant(*args, using=DEFAULT_DB_ALIAS, **kwargs):
"""Make sure default tenant exists"""
from django_tenants.utils import schema_context
@ -27,7 +27,11 @@ class AuthentikTenantsConfig(ManagedAppConfig):
verbose_name = "authentik Tenants"
default = True
def reconcile_global_load_checks(self):
"""Load tenant checks"""
self.import_module("authentik.tenants.checks")
def reconcile_global_default_tenant(self):
"""Make sure default tenant exists, especially after a migration"""
post_migrate.connect(reconcile_default_tenant)
reconcile_default_tenant()
post_migrate.connect(ensure_default_tenant)
ensure_default_tenant()

View File

@ -50,6 +50,10 @@ function set_mode {
trap cleanup EXIT
}
function run_django_checks {
python -m manage check --deploy
}
function cleanup {
rm -f ${MODE_FILE}
}
@ -67,6 +71,7 @@ fi
if [[ "$1" == "server" ]]; then
wait_for_db
set_mode "server"
run_django_checks
# If we have bootstrap credentials set, run bootstrap tasks outside of main server
# sync, so that we can sure the first start actually has working bootstrap
# credentials
@ -77,6 +82,7 @@ if [[ "$1" == "server" ]]; then
elif [[ "$1" == "worker" ]]; then
wait_for_db
set_mode "worker"
run_django_checks
check_if_root "python -m manage worker"
elif [[ "$1" == "worker-status" ]]; then
wait_for_db