Closed javierdelapuente closed 5 months ago
Test coverage for b6b5b09252580f963c9a7454bdbfa1cf8c646dac
Name Stmts Miss Branch BrPart Cover Missing
------------------------------------------------------------------------------------------
paas_app_charmer/__init__.py 0 0 0 0 100%
paas_app_charmer/_gunicorn/__init__.py 0 0 0 0 100%
paas_app_charmer/_gunicorn/charm.py 127 23 26 4 81% 59-61, 174-175, 177-178, 198->exit, 208-212, 236-238, 243-244, 248, 252, 256, 264, 268, 272, 276, 280
paas_app_charmer/_gunicorn/charm_state.py 57 1 6 1 97% 185
paas_app_charmer/_gunicorn/observability.py 19 0 0 0 100%
paas_app_charmer/_gunicorn/secret_storage.py 13 0 0 0 100%
paas_app_charmer/_gunicorn/webserver.py 75 5 16 2 92% 19, 155, 167-173
paas_app_charmer/_gunicorn/wsgi_app.py 60 0 24 0 100%
paas_app_charmer/database_migration.py 33 0 2 0 100%
paas_app_charmer/databases.py 18 0 4 0 100%
paas_app_charmer/django/__init__.py 1 0 0 0 100%
paas_app_charmer/django/charm.py 44 13 10 0 65% 72-77, 89, 97-114
paas_app_charmer/exceptions.py 4 0 0 0 100%
paas_app_charmer/flask/__init__.py 1 0 0 0 100%
paas_app_charmer/flask/charm.py 36 0 6 0 100%
paas_app_charmer/integrations.py 51 0 9 0 100%
paas_app_charmer/secret_storage.py 39 3 16 5 85% 50, 54->53, 55->57, 85, 104
------------------------------------------------------------------------------------------
TOTAL 578 45 119 12 91%
Static code analysis report
Run started:2024-05-29 13:33:45.478986
Test results:
No issues identified.
Code scanned:
Total lines of code: 1315
Total lines skipped (#nosec): 0
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):
closing as it will be done in another PR in a different way (being the conversion to env variables in the app instead)
Applicable spec:
Overview
This PR uses the
optional
attribute in therequires
key in thecharmcraft.yaml
file. Ifoptional
attribute is false for a declared integration, and that integration is not integrated or not correctly integrated, the charm blocks.For this PR, a refactor of how the integrations that can be optional work has been done. Now the CharmState has a field
integrations
that includes the integrations following a common API, Integration, that has two main methods:gen_environment
: Return the environment variables for the 12-factor app.block_charm
: If the charm should be blocked because of this integrations (because it is not integrated or the integrations is someway wrong).With this refactor, new integrations should be a little easier and more consistent.
Rationale
Currently, integrations do not block the charm, except if the
--check-config
check fails.For example, an application that requires a database or Redis can become active, even if it is not working. The natural way of Juju to work is to block the charm until the required integrations are correctly integrated, otherwise blocking the charm (see https://juju.is/docs/juju/status#heading--application-status).
This way, the charm developer can, in a very simple way, declare if the integration is optional or not for the charm, and the charm will wait until at least all the required integrations are ready.
Juju Events Changes
Module Changes
Library Changes
Checklist
src-docs
urgent
,trivial
,complex
)