Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: flask and django, update to paas-app-charmer 1.0.3 #1691

Merged
merged 9 commits into from
Jul 3, 2024
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"},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any worry with version 0 libs here that they'll make breaking changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for some reason it is common to start the versions on version 0 for charm libraries, I have seen it a lot. There generally shouldn't be breaking changes within any major version

Copy link
Contributor Author

@javierdelapuente javierdelapuente Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully LIBPATCH will not introduce non-breaking changes. https://juju.is/docs/sdk/document-your-charm-library.

I do not think the LIBAPI 0 has the usual semantics of semver with major number 0 (that any breaking change can happen). In the wild, we haven't had problems with that either.

{"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
Loading