Skip to content

Commit 6153055

Browse files
feat(smtp): Add SMTP integration to 12 Factor (#2199)
This PR is related to 12 Factor [SMTP PR](canonical/paas-charm#32). ## Rationale Some applications require an SMTP integration to send emails to their clients. This PR is a follow-up to the latest [12 Factor PR](canonical/paas-charm#32) for adding SMTP integration. ## Changes - Add commented-out SMTP relation required objects to extension charmcraft.yaml.j2 files. - Add references about SMTP into extension reference documents. - Add documentation about SMTP integration and generated environment variables - Add the smtp charm lib to the initializer. Reviewers: @jdkandersson @javierdelapuente @erinecon --------- Co-authored-by: Erin Conley <[email protected]>
1 parent 16bfbfc commit 6153055

File tree

11 files changed

+251
-765
lines changed

11 files changed

+251
-765
lines changed

charmcraft/extensions/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class _AppBase(Extension):
3838
{"lib": "data_platform_libs.s3", "version": "0"},
3939
{"lib": "saml_integrator.saml", "version": "0"},
4040
{"lib": "tempo_coordinator_k8s.tracing", "version": "0"},
41+
{"lib": "smtp_integrator.smtp", "version": "0"},
4142
]
4243

4344
@staticmethod

charmcraft/templates/init-django-framework/charmcraft.yaml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ extensions:
5959
# interface: tracing
6060
# optional: true
6161
# limit: 1
62+
# smtp:
63+
# interface: smtp
64+
# optional: false
65+
# limit: 1

charmcraft/templates/init-fastapi-framework/charmcraft.yaml.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,8 @@ extensions:
6161
# interface: tracing
6262
# optional: true
6363
# limit: 1
64+
# smtp:
65+
# interface: smtp
66+
# optional: false
67+
# limit: 1
68+

charmcraft/templates/init-flask-framework/charmcraft.yaml.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,8 @@ extensions:
5959
# interface: tracing
6060
# optional: true
6161
# limit: 1
62+
# smtp:
63+
# interface: smtp
64+
# optional: false
65+
# limit: 1
66+

charmcraft/templates/init-go-framework/charmcraft.yaml.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,8 @@ extensions:
6161
# interface: tracing
6262
# optional: true
6363
# limit: 1
64+
# smtp:
65+
# interface: smtp
66+
# optional: false
67+
# limit: 1
68+

docs/reference/extensions/django-framework-extension.rst

Lines changed: 4 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -63,202 +63,11 @@ will be set automatically.
6363

6464
.. include:: /reuse/reference/extensions/non_optional_config.rst
6565

66+
.. |base_url| replace:: ``DJANGO_BASE_URL``
67+
.. |juju_integrate_postgresql| replace:: ``juju integrate <django charm> postgresql``
68+
.. |framework| replace:: Django
6669

67-
``peers``, ``provides``, and ``requires`` keys
68-
----------------------------------------------
69-
70-
Your charm already has some ``peers``, ``provides``, and ``requires``
71-
integrations, for internal purposes.
72-
73-
.. dropdown:: Pre-populated integrations
74-
75-
.. code-block:: yaml
76-
77-
peers:
78-
secret-storage:
79-
interface: secret-storage
80-
provides:
81-
metrics-endpoint:
82-
interface: prometheus_scrape
83-
grafana-dashboard:
84-
interface: grafana_dashboard
85-
requires:
86-
logging:
87-
interface: loki_push_api
88-
ingress:
89-
interface: ingress
90-
limit: 1
91-
92-
In addition to these integrations, in each ``provides`` and ``requires``
93-
block you may specify further integration endpoints, to integrate with
94-
the following charms and bundles:
95-
96-
- Ingress: `traefik <https://charmhub.io/traefik-k8s>`__ and `nginx
97-
ingress integrator <https://charmhub.io/nginx-ingress-integrator>`__
98-
- MySQL: `machine <https://charmhub.io/mysql>`__ and
99-
`k8s <https://charmhub.io/mysql-k8s>`__ charm
100-
- PostgreSQL: `machine <https://charmhub.io/postgresql>`__ and
101-
`k8s <https://charmhub.io/postgresql-k8s>`__ charm
102-
- `MongoDB <https://charmhub.io/mongodb>`__
103-
- `Canonical Observability Stack
104-
(COS) <https://charmhub.io/cos-lite>`__
105-
- `Redis <https://charmhub.io/redis-k8s>`__
106-
- `SAML <https://charmhub.io/saml-integrator>`__
107-
- `S3 <https://charmhub.io/s3-integrator>`__
108-
- RabbitMQ: `machine <https://charmhub.io/rabbitmq-server>`__ and
109-
`k8s <https://charmhub.io/rabbitmq-k8s>`__ charm
110-
- `Tempo <https://charmhub.io/topics/charmed-tempo-ha>`__
111-
112-
These endpoint definitions are as below:
113-
114-
.. code-block:: yaml
115-
116-
requires:
117-
mysql:
118-
interface: mysql_client
119-
optional: True
120-
limit: 1
121-
122-
.. code-block:: yaml
123-
124-
requires:
125-
postgresql:
126-
interface: postgresql_client
127-
optional: True
128-
limit: 1
129-
130-
.. code-block:: yaml
131-
132-
requires:
133-
mongodb:
134-
interface: mongodb_client
135-
optional: True
136-
limit: 1
137-
138-
.. code-block:: yaml
139-
140-
requires:
141-
redis:
142-
interface: redis
143-
optional: True
144-
limit: 1
145-
146-
.. code-block:: yaml
147-
148-
requires:
149-
saml:
150-
interface: saml
151-
optional: True
152-
limit: 1
153-
154-
.. code-block:: yaml
155-
156-
requires:
157-
s3:
158-
interface: s3
159-
optional: True
160-
limit: 1
161-
162-
.. code-block:: yaml
163-
164-
requires:
165-
rabbitmq:
166-
interface: rabbitmq
167-
optional: True
168-
limit: 1
169-
170-
.. code-block:: yaml
171-
172-
requires:
173-
tracing:
174-
interface: tracing
175-
optional: True
176-
limit: 1
177-
178-
.. note::
179-
180-
The key ``optional`` with value ``False`` means that the charm will
181-
get blocked and stop the services if the integration is not provided.
182-
183-
To add one of these integrations, e.g., PostgreSQL, in the
184-
project file, include the appropriate requires block and
185-
integrate with ``juju integrate <django charm> postgresql`` as usual.
186-
187-
After the integration has been established, the connection string will
188-
be available as an environment variable. Integration with PostgreSQL,
189-
MySQL, MongoDB or Redis provides the string as the
190-
``POSTGRESQL_DB_CONNECT_STRING``, ``MYSQL_DB_CONNECT_STRING``,
191-
``MONGODB_DB_CONNECT_STRING`` or ``REDIS_DB_CONNECT_STRING`` environment
192-
variables respectively. Furthermore, the following environment variables
193-
will be provided to your Django application for integrations with
194-
PostgreSQL, MySQL, MongoDB or Redis:
195-
196-
- ``<integration>_DB_SCHEME``
197-
- ``<integration>_DB_NETLOC``
198-
- ``<integration>_DB_PATH``
199-
- ``<integration>_DB_PARAMS``
200-
- ``<integration>_DB_QUERY``
201-
- ``<integration>_DB_FRAGMENT``
202-
- ``<integration>_DB_USERNAME``
203-
- ``<integration>_DB_PASSWORD``
204-
- ``<integration>_DB_HOSTNAME``
205-
- ``<integration>_DB_PORT``
206-
- ``<integration>_DB_NAME``
207-
208-
Here, ``<integration>`` is replaced by ``POSTGRESQL``, ``MYSQL``
209-
``MONGODB`` or ``REDIS`` for the relevant integration. The key
210-
``optional`` with value ``False`` means that the charm will get blocked
211-
and stop the services if the integration is not provided.
212-
213-
The provided SAML environment variables are as follows:
214-
215-
- ``SAML_ENTITY_ID`` (required)
216-
- ``SAML_METADATA_URL`` (required)
217-
- ``SAML_SINGLE_SIGN_ON_REDIRECT_URL`` (required)
218-
- ``SAML_SIGNING_CERTIFICATE`` (required)
219-
220-
The S3 integration creates the following environment variables that you
221-
may use to configure your Flask application:
222-
223-
- ``S3_ACCESS_KEY`` (required)
224-
- ``S3_SECRET_KEY`` (required)
225-
- ``S3_BUCKET`` (required)
226-
- ``S3_REGION``
227-
- ``S3_STORAGE_CLASS``
228-
- ``S3_ENDPOINT``
229-
- ``S3_PATH``
230-
- ``S3_API_VERSION``
231-
- ``S3_URI_STYLE``
232-
- ``S3_ADDRESSING_STYLE``
233-
- ``S3_ATTRIBUTES``
234-
- ``S3_TLS_CA_CHAIN``
235-
236-
The RabbitMQ integration creates the connection string in the
237-
environment variable ``RABBITMQ_CONNECT_STRING``. Furthermore, the
238-
following environment variables may be provided, derived from the
239-
connection string:
240-
241-
- ``RABBITMQ_SCHEME``
242-
- ``RABBITMQ_NETLOC``
243-
- ``RABBITMQ_PATH``
244-
- ``RABBITMQ_PARAMS``
245-
- ``RABBITMQ_QUERY``
246-
- ``RABBITMQ_FRAGMENT``
247-
- ``RABBITMQ_USERNAME``
248-
- ``RABBITMQ_PASSWORD``
249-
- ``RABBITMQ_HOSTNAME``
250-
- ``RABBITMQ_PORT``
251-
- ``RABBITMQ_VHOST``
252-
253-
The Tracing integration creates the following environment variables
254-
that you can use to configure your application:
255-
256-
- ``OTEL_EXPORTER_OTLP_ENDPOINT``
257-
- ``OTEL_SERVICE_NAME``
258-
259-
The environment variable ``DJANGO_BASE_URL`` provides the Ingress URL
260-
for an Ingress integration or the Kubernetes service URL if there is no
261-
Ingress integration.
70+
.. include:: /reuse/reference/extensions/integrations.rst
26271

26372

26473
HTTP Proxy

0 commit comments

Comments
 (0)