Skip to content

Commit

Permalink
feat: flask and django, update to paas-app-charmer 1.0.3 (#1691)
Browse files Browse the repository at this point in the history
Version 1.0.3 of
[paas-app-charmer](https://github.com/canonical/paas-app-charmer) has
been released, providing the new following functionality:

- Two new integrations, SAML and S3.
- Blocking on non optional integrations. If the optional attribute in
the `charmcraft.yaml` file is set to false and the integration is not
active, paas-app-charmer will block the charm (and stop all the
services).

This PR adapts charmcraft to get advantage of that functionality.

Besides those changes, `charm-libs` has been added to the extension
(including the new two new libraries for SAML and S3). That way the user
can do `charmcraft fetch-libs` instead of one `fetch-lib` per library.
  • Loading branch information
javierdelapuente authored Jul 3, 2024
1 parent b48ef73 commit 775a0fc
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 8 deletions.
13 changes: 12 additions & 1 deletion charmcraft/extensions/gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _check_input(self) -> None:
f"{protected!r} in charmcraft.yaml conflicts with a reserved field "
f"in the {self.framework}-framework extension, please remove it."
)
for merging in ("actions", "requires", "provides", "config.options"):
for merging in ("actions", "requires", "provides", "config.options", "charm-libs"):
user_provided: dict[str, Any] = self._get_nested(self.yaml_data, merging)
if not user_provided:
continue
Expand Down Expand Up @@ -134,6 +134,17 @@ def _get_root_snippet(self) -> dict[str, Any]:
"description": f"{self.framework} application image.",
},
},
"charm-libs": [
{"lib": "traefik_k8s.ingress", "version": "2"},
{"lib": "observability_libs.juju_topology", "version": "0"},
{"lib": "grafana_k8s.grafana_dashboard", "version": "0"},
{"lib": "loki_k8s.loki_push_api", "version": "0"},
{"lib": "data_platform_libs.data_interfaces", "version": "0"},
{"lib": "prometheus_k8s.prometheus_scrape", "version": "0"},
{"lib": "redis_k8s.redis", "version": "0"},
{"lib": "data_platform_libs.s3", "version": "0"},
{"lib": "saml_integrator.saml", "version": "0"},
],
"peers": {"secret-storage": {"interface": "secret-storage"}},
"actions": self.actions,
"requires": {
Expand Down
20 changes: 20 additions & 0 deletions charmcraft/templates/init-django-framework/charmcraft.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,30 @@ extensions:
- django-framework

# Uncomment the integrations used by your application
# Integrations set to "optional: false" will block the charm
# until the applications are integrated.
# requires:
# mysql:
# interface: mysql_client
# optional: false
# limit: 1
# postgresql:
# interface: postgresql_client
# optional: false
# limit: 1
# mongodb:
# interface: mongodb_client
# optional: false
# limit: 1
# redis:
# interface: redis
# optional: false
# limit: 1
# s3:
# interface: s3
# optional: false
# limit: 1
# saml:
# interface: saml
# optional: false
# limit: 1
22 changes: 21 additions & 1 deletion charmcraft/templates/init-flask-framework/charmcraft.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bases:
channel: "22.04"

# (Required)
summary: A very short one-line summary of the flask application.
summary: A very short one-line summary of the Flask application.

# (Required)
description: |
Expand All @@ -24,10 +24,30 @@ extensions:
- flask-framework

# Uncomment the integrations used by your application
# Integrations set to "optional: false" will block the charm
# until the applications are integrated.
# requires:
# mysql:
# interface: mysql_client
# optional: false
# limit: 1
# postgresql:
# interface: postgresql_client
# optional: false
# limit: 1
# mongodb:
# interface: mongodb_client
# optional: false
# limit: 1
# redis:
# interface: redis
# optional: false
# limit: 1
# s3:
# interface: s3
# optional: false
# limit: 1
# saml:
# interface: saml
# optional: false
# limit: 1
22 changes: 22 additions & 0 deletions tests/extensions/test_gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ def flask_input_yaml_fixture():
},
"description": "test description",
"name": "test-flask",
"charm-libs": [
{"lib": "traefik_k8s.ingress", "version": "2"},
{"lib": "observability_libs.juju_topology", "version": "0"},
{"lib": "grafana_k8s.grafana_dashboard", "version": "0"},
{"lib": "loki_k8s.loki_push_api", "version": "0"},
{"lib": "data_platform_libs.data_interfaces", "version": "0"},
{"lib": "prometheus_k8s.prometheus_scrape", "version": "0"},
{"lib": "redis_k8s.redis", "version": "0"},
{"lib": "data_platform_libs.s3", "version": "0"},
{"lib": "saml_integrator.saml", "version": "0"},
],
"config": {
"options": {**FlaskFramework.options, **FlaskFramework._WEBSERVER_OPTIONS}
},
Expand Down Expand Up @@ -93,6 +104,17 @@ def flask_input_yaml_fixture():
},
"description": "test description",
"name": "test-django",
"charm-libs": [
{"lib": "traefik_k8s.ingress", "version": "2"},
{"lib": "observability_libs.juju_topology", "version": "0"},
{"lib": "grafana_k8s.grafana_dashboard", "version": "0"},
{"lib": "loki_k8s.loki_push_api", "version": "0"},
{"lib": "data_platform_libs.data_interfaces", "version": "0"},
{"lib": "prometheus_k8s.prometheus_scrape", "version": "0"},
{"lib": "redis_k8s.redis", "version": "0"},
{"lib": "data_platform_libs.s3", "version": "0"},
{"lib": "saml_integrator.saml", "version": "0"},
],
"config": {
"options": {**DjangoFramework.options, **DjangoFramework._WEBSERVER_OPTIONS}
},
Expand Down
7 changes: 1 addition & 6 deletions tests/spread/commands/init-flask-framework/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ execute: |
mkdir -p test-init
cd test-init
charmcraft init --profile flask-framework
charmcraft fetch-lib charms.traefik_k8s.v2.ingress
charmcraft fetch-lib charms.observability_libs.v0.juju_topology
charmcraft fetch-lib charms.grafana_k8s.v0.grafana_dashboard
charmcraft fetch-lib charms.loki_k8s.v0.loki_push_api
charmcraft fetch-lib charms.data_platform_libs.v0.data_interfaces
charmcraft fetch-lib charms.prometheus_k8s.v0.prometheus_scrape
charmcraft fetch-libs
charmcraft pack --verbose
test -f *.charm
Expand Down

0 comments on commit 775a0fc

Please sign in to comment.