canonical / paas-app-charmer

2 stars 2 forks source link

Require a database for Django to start #42

Closed javierdelapuente closed 2 months ago

javierdelapuente commented 2 months ago

Applicable spec:

Overview

In Django there is always a manage.py file. This file is created by the django-admin command, and will be used by the charm to run the migrations.

As so, if there is no database integration correctly configured, the migration will fail (we do not support the sqlite3 local database). Many of the default Django apps (admin/sessions/auth) use the database, so the database is expected to be correctly configured.

This PR blocks the charm if there is no database integration correctly configured for Django. This can be for two reasons, one is no database defined in charmcraft.yaml, the other is that there is only optional databases that were not integrated.

Rationale

Juju Events Changes

Module Changes

Library Changes

Checklist

github-actions[bot] commented 2 months ago

Test coverage for cbcd8a4c01cd8e29de540f94961d381bf702e996

Name                                            Stmts   Miss Branch BrPart  Cover   Missing
-------------------------------------------------------------------------------------------
paas_app_charmer/__init__.py                       32     17      0      0    47%   13-14, 19-20, 26-27, 33-37, 43-44, 50-51, 57-58
paas_app_charmer/_gunicorn/__init__.py              0      0      0      0   100%
paas_app_charmer/_gunicorn/charm.py                15      0      0      0   100%
paas_app_charmer/_gunicorn/webserver.py            83      4     16      1    95%   175, 187-193
paas_app_charmer/_gunicorn/workload_config.py       8      0      0      0   100%
paas_app_charmer/_gunicorn/wsgi_app.py             16      0      0      0   100%
paas_app_charmer/app.py                           138      0     56      3    98%   95->exit, 145->151, 306->308
paas_app_charmer/charm.py                         232     25     52      4    89%   33-34, 41-42, 205-206, 208-209, 230->exit, 242-246, 303-305, 359-360, 365, 370, 375, 385, 390, 395, 400, 405, 430
paas_app_charmer/charm_state.py                   108      2     20      2    97%   187, 276
paas_app_charmer/charm_utils.py                    23      0      0      0   100%
paas_app_charmer/database_migration.py             35      0      2      0   100%
paas_app_charmer/databases.py                      25      2     11      1    92%   89-90
paas_app_charmer/django/__init__.py                 2      0      0      0   100%
paas_app_charmer/django/charm.py                   42      4     10      2    88%   44, 104, 119-120
paas_app_charmer/exceptions.py                      5      0      0      0   100%
paas_app_charmer/fastapi/__init__.py                2      0      0      0   100%
paas_app_charmer/fastapi/charm.py                  29      0      0      0   100%
paas_app_charmer/flask/__init__.py                  2      0      0      0   100%
paas_app_charmer/flask/charm.py                    24      0      0      0   100%
paas_app_charmer/go/__init__.py                     2      0      0      0   100%
paas_app_charmer/go/charm.py                       26      0      0      0   100%
paas_app_charmer/observability.py                  24      3      8      1    81%   41->45, 72-76
paas_app_charmer/rabbitmq.py                       78      2     22      5    93%   117->exit, 122->exit, 157->exit, 159-160, 181->175
paas_app_charmer/secret_storage.py                 50      3     16      5    88%   51, 55->54, 56->58, 86, 105
paas_app_charmer/utils.py                          21      4     14      2    71%   30, 32, 52-53
-------------------------------------------------------------------------------------------
TOTAL                                            1022     66    227     26    92%

Static code analysis report

Run started:2024-09-11 15:34:43.864941

Test results:
    No issues identified.

Code scanned:
    Total lines of code: 2216
    Total lines skipped (#nosec): 1
    Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
    Total issues (by severity):
        Undefined: 0
        Low: 0
        Medium: 0
        High: 0
    Total issues (by confidence):
        Undefined: 0
        Low: 0
        Medium: 0
        High: 0
Files skipped (0):