diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2c72f16..0e4277b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest environment: name: release - url: https://pypi.org/p/paas-app-charmer + url: https://pypi.org/p/paas-charm permissions: id-token: write if: github.event_name == 'workflow_dispatch' diff --git a/README.md b/README.md index 18f3742..3eec37d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PaaS App Charmer +# PaaS Charm Easily deploy and operate your Flask or Django applications and associated infrastructure, such as databases and ingress, using open source tooling. This @@ -8,7 +8,7 @@ developed by Canonical, the creators of Ubuntu. Have you ever created an application and then wanted to deploy it for your users only to either be forced to use a proprietary public cloud platform or manage -the deployment and operations yourself? PaaS App Charmer will take your +the deployment and operations yourself? PaaS Charm will take your application and create an OCI image using Rockcraft and operations code using Charmcraft for you. The full suite of tools is open source so you can see exactly how it works and even contribute! After creating the app charm and @@ -64,7 +64,7 @@ Additional resources: ## Contributing -Is there something missing from the PaaS App Charmer framework? PaaS App Charmer +Is there something missing from the PaaS Charm framework? PaaS Charm welcomes contributions! This section covers how to add a new integration and a new framework. @@ -77,13 +77,13 @@ through below. [charm topic on discourse](https://discourse.charmhub.io/c/charm/41). This should cover things like: * The integration you intend add - * For each of the frameworks that PaaS App Charmer supports: + * For each of the frameworks that PaaS Charm supports: - The commonly used package(s) to make use of the integration - The environment variables, configuration etc. that would be made available to the app - An example for how to use the integration within an app - * The proposed implementation in `paas-app-charmer`. Take a look at - [`charm.py`](paas_app_charmer/_gunicorn/charm.py) for `gunicorn` based + * The proposed implementation in `paas-app`. Take a look at + [`charm.py`](paas_charm/_gunicorn/charm.py) for `gunicorn` based frameworks for integration examples. 1. Update the [reference](https://juju.is/docs/sdk/charmcraft-extension-flask-framework) @@ -113,7 +113,7 @@ below. * How the configuration options of the charm map to environment variables, configurations or another method of passing the information to the app * The requirements and conventions for how users need to configure their app - to work with PaaS App Charmer + to work with PaaS Charm * Which web server to use 1. Raise a pull request to [rockcraft](https://github.com/canonical/rockcraft) adding a new extension and profile for the framework. This is the flask @@ -124,7 +124,7 @@ below. framework. 1. Raise a pull request to this repository adding a new parent class that can be used by the app charms. The following is the - [example for flask](./paas_app_charmer/flask/charm.py). + [example for flask](./paas_charm/flask/charm.py). 1. Raise a pull request to [charmcraft](https://github.com/canonical/charmcraft) adding a new extension and profile for the framework. This is the flask diff --git a/examples/django/charm/src/charm.py b/examples/django/charm/src/charm.py index ab6f2d7..5199852 100755 --- a/examples/django/charm/src/charm.py +++ b/examples/django/charm/src/charm.py @@ -10,12 +10,12 @@ import ops -import paas_app_charmer.django +import paas_charm.django logger = logging.getLogger(__name__) -class DjangoCharm(paas_app_charmer.django.Charm): +class DjangoCharm(paas_charm.django.Charm): """Django Charm service.""" def __init__(self, *args: typing.Any) -> None: diff --git a/examples/fastapi/charm/src/charm.py b/examples/fastapi/charm/src/charm.py index bc363f5..63b54c1 100755 --- a/examples/fastapi/charm/src/charm.py +++ b/examples/fastapi/charm/src/charm.py @@ -9,10 +9,10 @@ import ops -import paas_app_charmer.fastapi +import paas_charm.fastapi -class FastAPICharm(paas_app_charmer.fastapi.Charm): +class FastAPICharm(paas_charm.fastapi.Charm): """FastAPI Charm service.""" def __init__(self, *args: typing.Any) -> None: diff --git a/examples/flask/src/charm.py b/examples/flask/src/charm.py index f1e1eb1..1274e26 100755 --- a/examples/flask/src/charm.py +++ b/examples/flask/src/charm.py @@ -9,12 +9,12 @@ import ops -import paas_app_charmer.flask +import paas_charm.flask logger = logging.getLogger(__name__) -class FlaskCharm(paas_app_charmer.flask.Charm): +class FlaskCharm(paas_charm.flask.Charm): """Flask Charm service.""" def __init__(self, *args: typing.Any) -> None: diff --git a/examples/go/charm/src/charm.py b/examples/go/charm/src/charm.py index 384445c..0336590 100755 --- a/examples/go/charm/src/charm.py +++ b/examples/go/charm/src/charm.py @@ -9,10 +9,10 @@ import ops -import paas_app_charmer.go +import paas_charm.go -class GoCharm(paas_app_charmer.go.Charm): +class GoCharm(paas_charm.go.Charm): """Go Charm service.""" def __init__(self, *args: typing.Any) -> None: diff --git a/pyproject.toml b/pyproject.toml index 35c2d40..2b98188 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,9 @@ # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. [project] -name = "paas-app-charmer" -version = "1.3.1" -description = "Companion library for PaaS app charmer." +name = "paas-charm" +version = "1.0.0" +description = "Companion library for 12-factor app support in Charmcraft & Rockcraft." readme = "README.md" authors = [ {name = "Canonical IS DevOps team", email="is-devops-team@canonical.com"}, @@ -20,13 +20,13 @@ classifiers = [ [project.urls] -Repository = "https://github.com/canonical/paas-app-charmer" +Repository = "https://github.com/canonical/paas-charm" [tool.setuptools.dynamic] dependencies = {file = ["requirements.txt"]} [tool.setuptools.package-data] -paas_app_charmer = ["**/cos/**", "**/cos/**/.**"] +paas_charm = ["**/cos/**", "**/cos/**/.**"] # Testing tools configuration [tool.coverage.run] diff --git a/src/paas_app_charmer/__init__.py b/src/paas_app_charmer/__init__.py new file mode 100644 index 0000000..10d681f --- /dev/null +++ b/src/paas_app_charmer/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Deprecated entrypoints for charms. + +This module can be removed when paas_charm>=2.0. + +It has to be maintained for the life cycle of bases 22.04 and 24.04. +""" + +import warnings + +warnings.warn("paas_app_charmer package is deprecated", DeprecationWarning, stacklevel=2) diff --git a/src/paas_app_charmer/django/__init__.py b/src/paas_app_charmer/django/__init__.py new file mode 100644 index 0000000..0a40a7f --- /dev/null +++ b/src/paas_app_charmer/django/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Deprecated Django module entrypoint. + +This module can be removed when paas_charm>=2.0. + +It has to be maintained for the life cycle of bases 22.04 and 24.04. +""" + +from .charm import Charm + +__all__ = ["Charm"] diff --git a/src/paas_app_charmer/django/charm.py b/src/paas_app_charmer/django/charm.py new file mode 100644 index 0000000..e27606d --- /dev/null +++ b/src/paas_app_charmer/django/charm.py @@ -0,0 +1,15 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Deprecated Django Charm service. + +This module can be removed when paas_charm>=2.0. + +It has to be maintained for the life cycle of bases 22.04 and 24.04. +""" + +import paas_charm.django.charm + + +class Charm(paas_charm.django.charm.Charm): + """Deprecated Django charm.""" diff --git a/src/paas_app_charmer/fastapi/__init__.py b/src/paas_app_charmer/fastapi/__init__.py new file mode 100644 index 0000000..619b31a --- /dev/null +++ b/src/paas_app_charmer/fastapi/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Deprecated FastAPI module entrypoint. + +This module can be removed when paas_charm>=2.0. + +It has to be maintained for the life cycle of bases 22.04 and 24.04. +""" + +from .charm import Charm + +__all__ = ["Charm"] diff --git a/src/paas_app_charmer/fastapi/charm.py b/src/paas_app_charmer/fastapi/charm.py new file mode 100644 index 0000000..4c00de8 --- /dev/null +++ b/src/paas_app_charmer/fastapi/charm.py @@ -0,0 +1,16 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + + +"""Deprecated FastAPI Charm service. + +This module can be removed when paas_charm>=2.0. + +It has to be maintained for the life cycle of bases 22.04 and 24.04. +""" + +import paas_charm.fastapi.charm + + +class Charm(paas_charm.fastapi.charm.Charm): + """Deprecated FastAPI charm.""" diff --git a/src/paas_app_charmer/flask/__init__.py b/src/paas_app_charmer/flask/__init__.py new file mode 100644 index 0000000..e67d19a --- /dev/null +++ b/src/paas_app_charmer/flask/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Deprecated Flask module entrypoint. + +This module can be removed when paas_charm>=2.0. + +It has to be maintained for the life cycle of bases 22.04 and 24.04. +""" + +from .charm import Charm + +__all__ = ["Charm"] diff --git a/src/paas_app_charmer/flask/charm.py b/src/paas_app_charmer/flask/charm.py new file mode 100644 index 0000000..6dd97fe --- /dev/null +++ b/src/paas_app_charmer/flask/charm.py @@ -0,0 +1,15 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Deprecated Flask Charm service. + +This module can be removed when paas_charm>=2.0. + +It has to be maintained for the life cycle of bases 22.04 and 24.04. +""" + +import paas_charm.flask.charm + + +class Charm(paas_charm.flask.charm.Charm): + """Deprecated Flask charm.""" diff --git a/src/paas_app_charmer/go/__init__.py b/src/paas_app_charmer/go/__init__.py new file mode 100644 index 0000000..3eade92 --- /dev/null +++ b/src/paas_app_charmer/go/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Deprecated Go module entrypoint. + +This module can be removed when paas_charm>=2.0. + +It has to be maintained for the life cycle of bases 22.04 and 24.04. +""" + +from .charm import Charm + +__all__ = ["Charm"] diff --git a/src/paas_app_charmer/go/charm.py b/src/paas_app_charmer/go/charm.py new file mode 100644 index 0000000..ad8a3fa --- /dev/null +++ b/src/paas_app_charmer/go/charm.py @@ -0,0 +1,16 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Deprecated Go Charm service. + +This module can be removed when paas_charm>=2.0. + +It has to be maintained for the life cycle of bases 22.04 and 24.04. +""" + + +import paas_charm.go.charm + + +class Charm(paas_charm.go.charm.Charm): + """Deprecated Go charm.""" diff --git a/paas_app_charmer/__init__.py b/src/paas_charm/__init__.py similarity index 98% rename from paas_app_charmer/__init__.py rename to src/paas_charm/__init__.py index 71d9dfb..2457d3c 100644 --- a/paas_app_charmer/__init__.py +++ b/src/paas_charm/__init__.py @@ -5,7 +5,7 @@ """Module __init__.""" -from paas_app_charmer import exceptions +from paas_charm import exceptions # Try the charm library imports to check whether they are present try: diff --git a/paas_app_charmer/_gunicorn/__init__.py b/src/paas_charm/_gunicorn/__init__.py similarity index 100% rename from paas_app_charmer/_gunicorn/__init__.py rename to src/paas_charm/_gunicorn/__init__.py diff --git a/paas_app_charmer/_gunicorn/charm.py b/src/paas_charm/_gunicorn/charm.py similarity index 79% rename from paas_app_charmer/_gunicorn/charm.py rename to src/paas_charm/_gunicorn/charm.py index ad749eb..0273687 100644 --- a/paas_app_charmer/_gunicorn/charm.py +++ b/src/paas_charm/_gunicorn/charm.py @@ -4,11 +4,11 @@ """The base charm class for all charms.""" import logging -from paas_app_charmer._gunicorn.webserver import GunicornWebserver, WebserverConfig -from paas_app_charmer._gunicorn.workload_config import create_workload_config -from paas_app_charmer._gunicorn.wsgi_app import WsgiApp -from paas_app_charmer.app import App, WorkloadConfig -from paas_app_charmer.charm import PaasCharm +from paas_charm._gunicorn.webserver import GunicornWebserver, WebserverConfig +from paas_charm._gunicorn.workload_config import create_workload_config +from paas_charm._gunicorn.wsgi_app import WsgiApp +from paas_charm.app import App, WorkloadConfig +from paas_charm.charm import PaasCharm logger = logging.getLogger(__name__) diff --git a/paas_app_charmer/_gunicorn/webserver.py b/src/paas_charm/_gunicorn/webserver.py similarity index 97% rename from paas_app_charmer/_gunicorn/webserver.py rename to src/paas_charm/_gunicorn/webserver.py index 3061a85..854ed72 100644 --- a/paas_app_charmer/_gunicorn/webserver.py +++ b/src/paas_charm/_gunicorn/webserver.py @@ -14,14 +14,14 @@ import ops from ops.pebble import ExecError, PathError -from paas_app_charmer._gunicorn.workload_config import ( +from paas_charm._gunicorn.workload_config import ( APPLICATION_ERROR_LOG_FILE_FMT, APPLICATION_LOG_FILE_FMT, STATSD_HOST, ) -from paas_app_charmer.app import WorkloadConfig -from paas_app_charmer.exceptions import CharmConfigInvalidError -from paas_app_charmer.utils import enable_pebble_log_forwarding +from paas_charm.app import WorkloadConfig +from paas_charm.exceptions import CharmConfigInvalidError +from paas_charm.utils import enable_pebble_log_forwarding logger = logging.getLogger(__name__) diff --git a/paas_app_charmer/_gunicorn/workload_config.py b/src/paas_charm/_gunicorn/workload_config.py similarity index 96% rename from paas_app_charmer/_gunicorn/workload_config.py rename to src/paas_charm/_gunicorn/workload_config.py index d93bbf3..f0e8d0c 100644 --- a/paas_app_charmer/_gunicorn/workload_config.py +++ b/src/paas_charm/_gunicorn/workload_config.py @@ -5,7 +5,7 @@ import pathlib -from paas_app_charmer.app import WorkloadConfig +from paas_charm.app import WorkloadConfig STATSD_HOST = "localhost:9125" APPLICATION_LOG_FILE_FMT = "/var/log/{framework}/access.log" diff --git a/paas_app_charmer/_gunicorn/wsgi_app.py b/src/paas_charm/_gunicorn/wsgi_app.py similarity index 88% rename from paas_app_charmer/_gunicorn/wsgi_app.py rename to src/paas_charm/_gunicorn/wsgi_app.py index 924bee3..e5a5a20 100644 --- a/paas_app_charmer/_gunicorn/wsgi_app.py +++ b/src/paas_charm/_gunicorn/wsgi_app.py @@ -7,10 +7,10 @@ import ops -from paas_app_charmer._gunicorn.webserver import GunicornWebserver -from paas_app_charmer.app import App, WorkloadConfig -from paas_app_charmer.charm_state import CharmState -from paas_app_charmer.database_migration import DatabaseMigration +from paas_charm._gunicorn.webserver import GunicornWebserver +from paas_charm.app import App, WorkloadConfig +from paas_charm.charm_state import CharmState +from paas_charm.database_migration import DatabaseMigration logger = logging.getLogger(__name__) diff --git a/paas_app_charmer/app.py b/src/paas_charm/app.py similarity index 99% rename from paas_app_charmer/app.py rename to src/paas_charm/app.py index 707f8a9..728abfc 100644 --- a/paas_app_charmer/app.py +++ b/src/paas_charm/app.py @@ -12,8 +12,8 @@ import ops -from paas_app_charmer.charm_state import CharmState, IntegrationsState -from paas_app_charmer.database_migration import DatabaseMigration +from paas_charm.charm_state import CharmState, IntegrationsState +from paas_charm.database_migration import DatabaseMigration logger = logging.getLogger(__name__) diff --git a/paas_app_charmer/charm.py b/src/paas_charm/charm.py similarity index 96% rename from paas_app_charmer/charm.py rename to src/paas_charm/charm.py index 737ad16..346a885 100644 --- a/paas_app_charmer/charm.py +++ b/src/paas_charm/charm.py @@ -13,16 +13,16 @@ from ops.model import Container from pydantic import BaseModel, ValidationError -from paas_app_charmer.app import App, WorkloadConfig -from paas_app_charmer.charm_state import CharmState -from paas_app_charmer.charm_utils import block_if_invalid_config -from paas_app_charmer.database_migration import DatabaseMigration, DatabaseMigrationStatus -from paas_app_charmer.databases import make_database_requirers -from paas_app_charmer.exceptions import CharmConfigInvalidError -from paas_app_charmer.observability import Observability -from paas_app_charmer.rabbitmq import RabbitMQRequires -from paas_app_charmer.secret_storage import KeySecretStorage -from paas_app_charmer.utils import build_validation_error_message, config_get_with_secret +from paas_charm.app import App, WorkloadConfig +from paas_charm.charm_state import CharmState +from paas_charm.charm_utils import block_if_invalid_config +from paas_charm.database_migration import DatabaseMigration, DatabaseMigrationStatus +from paas_charm.databases import make_database_requirers +from paas_charm.exceptions import CharmConfigInvalidError +from paas_charm.observability import Observability +from paas_charm.rabbitmq import RabbitMQRequires +from paas_charm.secret_storage import KeySecretStorage +from paas_charm.utils import build_validation_error_message, config_get_with_secret logger = logging.getLogger(__name__) diff --git a/paas_app_charmer/charm_state.py b/src/paas_charm/charm_state.py similarity index 98% rename from paas_app_charmer/charm_state.py rename to src/paas_charm/charm_state.py index 022450b..98b3247 100644 --- a/paas_app_charmer/charm_state.py +++ b/src/paas_charm/charm_state.py @@ -12,10 +12,10 @@ from charms.data_platform_libs.v0.data_interfaces import DatabaseRequires from pydantic import BaseModel, Extra, Field, ValidationError, ValidationInfo, field_validator -from paas_app_charmer.databases import get_uri -from paas_app_charmer.exceptions import CharmConfigInvalidError -from paas_app_charmer.secret_storage import KeySecretStorage -from paas_app_charmer.utils import build_validation_error_message +from paas_charm.databases import get_uri +from paas_charm.exceptions import CharmConfigInvalidError +from paas_charm.secret_storage import KeySecretStorage +from paas_charm.utils import build_validation_error_message logger = logging.getLogger(__name__) diff --git a/paas_app_charmer/charm_utils.py b/src/paas_charm/charm_utils.py similarity index 93% rename from paas_app_charmer/charm_utils.py rename to src/paas_charm/charm_utils.py index ffd6157..a8afb98 100644 --- a/paas_app_charmer/charm_utils.py +++ b/src/paas_charm/charm_utils.py @@ -8,8 +8,8 @@ import ops -from paas_app_charmer.charm_state import CharmState -from paas_app_charmer.exceptions import CharmConfigInvalidError +from paas_charm.charm_state import CharmState +from paas_charm.exceptions import CharmConfigInvalidError logger = logging.getLogger(__name__) diff --git a/paas_app_charmer/database_migration.py b/src/paas_charm/database_migration.py similarity index 98% rename from paas_app_charmer/database_migration.py rename to src/paas_charm/database_migration.py index 2d58bcc..27eda9c 100644 --- a/paas_app_charmer/database_migration.py +++ b/src/paas_charm/database_migration.py @@ -10,7 +10,7 @@ import ops from ops.pebble import ExecError -from paas_app_charmer.exceptions import CharmConfigInvalidError +from paas_charm.exceptions import CharmConfigInvalidError logger = logging.getLogger(__name__) diff --git a/paas_app_charmer/databases.py b/src/paas_charm/databases.py similarity index 100% rename from paas_app_charmer/databases.py rename to src/paas_charm/databases.py diff --git a/paas_app_charmer/django/__init__.py b/src/paas_charm/django/__init__.py similarity index 100% rename from paas_app_charmer/django/__init__.py rename to src/paas_charm/django/__init__.py diff --git a/paas_app_charmer/django/charm.py b/src/paas_charm/django/charm.py similarity index 97% rename from paas_app_charmer/django/charm.py rename to src/paas_charm/django/charm.py index 8f72005..310291d 100644 --- a/paas_app_charmer/django/charm.py +++ b/src/paas_charm/django/charm.py @@ -10,8 +10,8 @@ import ops from pydantic import ConfigDict, Field, validator -from paas_app_charmer._gunicorn.charm import GunicornBase -from paas_app_charmer.framework import FrameworkConfig +from paas_charm._gunicorn.charm import GunicornBase +from paas_charm.framework import FrameworkConfig logger = logging.getLogger(__name__) diff --git a/paas_app_charmer/django/cos/grafana_dashboards/django.json b/src/paas_charm/django/cos/grafana_dashboards/django.json similarity index 100% rename from paas_app_charmer/django/cos/grafana_dashboards/django.json rename to src/paas_charm/django/cos/grafana_dashboards/django.json diff --git a/paas_app_charmer/django/cos/loki_alert_rules/.gitkeep b/src/paas_charm/django/cos/loki_alert_rules/.gitkeep similarity index 100% rename from paas_app_charmer/django/cos/loki_alert_rules/.gitkeep rename to src/paas_charm/django/cos/loki_alert_rules/.gitkeep diff --git a/paas_app_charmer/django/cos/prometheus_alert_rules/django.rule b/src/paas_charm/django/cos/prometheus_alert_rules/django.rule similarity index 100% rename from paas_app_charmer/django/cos/prometheus_alert_rules/django.rule rename to src/paas_charm/django/cos/prometheus_alert_rules/django.rule diff --git a/paas_app_charmer/exceptions.py b/src/paas_charm/exceptions.py similarity index 100% rename from paas_app_charmer/exceptions.py rename to src/paas_charm/exceptions.py diff --git a/paas_app_charmer/fastapi/__init__.py b/src/paas_charm/fastapi/__init__.py similarity index 100% rename from paas_app_charmer/fastapi/__init__.py rename to src/paas_charm/fastapi/__init__.py diff --git a/paas_app_charmer/fastapi/charm.py b/src/paas_charm/fastapi/charm.py similarity index 95% rename from paas_app_charmer/fastapi/charm.py rename to src/paas_charm/fastapi/charm.py index 673080b..c13f2a3 100644 --- a/paas_app_charmer/fastapi/charm.py +++ b/src/paas_charm/fastapi/charm.py @@ -9,9 +9,9 @@ import ops from pydantic import ConfigDict, Field -from paas_app_charmer.app import App, WorkloadConfig -from paas_app_charmer.charm import PaasCharm -from paas_app_charmer.framework import FrameworkConfig +from paas_charm.app import App, WorkloadConfig +from paas_charm.charm import PaasCharm +from paas_charm.framework import FrameworkConfig class FastAPIConfig(FrameworkConfig): diff --git a/paas_app_charmer/flask/__init__.py b/src/paas_charm/flask/__init__.py similarity index 100% rename from paas_app_charmer/flask/__init__.py rename to src/paas_charm/flask/__init__.py diff --git a/paas_app_charmer/flask/charm.py b/src/paas_charm/flask/charm.py similarity index 96% rename from paas_app_charmer/flask/charm.py rename to src/paas_charm/flask/charm.py index ca83a31..bd20ab9 100644 --- a/paas_app_charmer/flask/charm.py +++ b/src/paas_charm/flask/charm.py @@ -8,8 +8,8 @@ import ops from pydantic import ConfigDict, Field, field_validator -from paas_app_charmer._gunicorn.charm import GunicornBase -from paas_app_charmer.framework import FrameworkConfig +from paas_charm._gunicorn.charm import GunicornBase +from paas_charm.framework import FrameworkConfig logger = logging.getLogger(__name__) diff --git a/paas_app_charmer/flask/cos/grafana_dashboards/flask.json b/src/paas_charm/flask/cos/grafana_dashboards/flask.json similarity index 100% rename from paas_app_charmer/flask/cos/grafana_dashboards/flask.json rename to src/paas_charm/flask/cos/grafana_dashboards/flask.json diff --git a/paas_app_charmer/flask/cos/loki_alert_rules/.gitkeep b/src/paas_charm/flask/cos/loki_alert_rules/.gitkeep similarity index 100% rename from paas_app_charmer/flask/cos/loki_alert_rules/.gitkeep rename to src/paas_charm/flask/cos/loki_alert_rules/.gitkeep diff --git a/paas_app_charmer/flask/cos/prometheus_alert_rules/flask.rule b/src/paas_charm/flask/cos/prometheus_alert_rules/flask.rule similarity index 100% rename from paas_app_charmer/flask/cos/prometheus_alert_rules/flask.rule rename to src/paas_charm/flask/cos/prometheus_alert_rules/flask.rule diff --git a/paas_app_charmer/framework.py b/src/paas_charm/framework.py similarity index 100% rename from paas_app_charmer/framework.py rename to src/paas_charm/framework.py diff --git a/paas_app_charmer/go/__init__.py b/src/paas_charm/go/__init__.py similarity index 100% rename from paas_app_charmer/go/__init__.py rename to src/paas_charm/go/__init__.py diff --git a/paas_app_charmer/go/charm.py b/src/paas_charm/go/charm.py similarity index 94% rename from paas_app_charmer/go/charm.py rename to src/paas_charm/go/charm.py index cea2678..92b18f8 100644 --- a/paas_app_charmer/go/charm.py +++ b/src/paas_charm/go/charm.py @@ -9,9 +9,9 @@ import ops from pydantic import ConfigDict, Field -from paas_app_charmer.app import App, WorkloadConfig -from paas_app_charmer.charm import PaasCharm -from paas_app_charmer.framework import FrameworkConfig +from paas_charm.app import App, WorkloadConfig +from paas_charm.charm import PaasCharm +from paas_charm.framework import FrameworkConfig class GoConfig(FrameworkConfig): diff --git a/paas_app_charmer/go/cos/grafana_dashboards/go.json b/src/paas_charm/go/cos/grafana_dashboards/go.json similarity index 100% rename from paas_app_charmer/go/cos/grafana_dashboards/go.json rename to src/paas_charm/go/cos/grafana_dashboards/go.json diff --git a/paas_app_charmer/go/cos/loki_alert_rules/.gitkeep b/src/paas_charm/go/cos/loki_alert_rules/.gitkeep similarity index 100% rename from paas_app_charmer/go/cos/loki_alert_rules/.gitkeep rename to src/paas_charm/go/cos/loki_alert_rules/.gitkeep diff --git a/paas_app_charmer/go/cos/prometheus_alert_rules/.gitkeep b/src/paas_charm/go/cos/prometheus_alert_rules/.gitkeep similarity index 100% rename from paas_app_charmer/go/cos/prometheus_alert_rules/.gitkeep rename to src/paas_charm/go/cos/prometheus_alert_rules/.gitkeep diff --git a/paas_app_charmer/observability.py b/src/paas_charm/observability.py similarity index 98% rename from paas_app_charmer/observability.py rename to src/paas_charm/observability.py index cd82489..0ee39f7 100644 --- a/paas_app_charmer/observability.py +++ b/src/paas_charm/observability.py @@ -9,7 +9,7 @@ from charms.grafana_k8s.v0.grafana_dashboard import GrafanaDashboardProvider from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointProvider -from paas_app_charmer.utils import enable_pebble_log_forwarding +from paas_charm.utils import enable_pebble_log_forwarding class Observability(ops.Object): diff --git a/paas_app_charmer/rabbitmq.py b/src/paas_charm/rabbitmq.py similarity index 100% rename from paas_app_charmer/rabbitmq.py rename to src/paas_charm/rabbitmq.py diff --git a/paas_app_charmer/secret_storage.py b/src/paas_charm/secret_storage.py similarity index 100% rename from paas_app_charmer/secret_storage.py rename to src/paas_charm/secret_storage.py diff --git a/paas_app_charmer/utils.py b/src/paas_charm/utils.py similarity index 100% rename from paas_app_charmer/utils.py rename to src/paas_charm/utils.py diff --git a/tests/integration/django/conftest.py b/tests/integration/django/conftest.py index 42d299c..b93c3e8 100644 --- a/tests/integration/django/conftest.py +++ b/tests/integration/django/conftest.py @@ -44,7 +44,7 @@ async def charm_file_fixture( charm_file = await ops_test.build_charm(PROJECT_ROOT / "examples/django/charm") elif charm_file[0] != "/": charm_file = PROJECT_ROOT / charm_file - inject_venv(charm_file, PROJECT_ROOT / "paas_app_charmer") + inject_venv(charm_file, PROJECT_ROOT / "src" / "paas_charm") return inject_charm_config( charm_file, { diff --git a/tests/integration/fastapi/conftest.py b/tests/integration/fastapi/conftest.py index 9c312d3..3211232 100644 --- a/tests/integration/fastapi/conftest.py +++ b/tests/integration/fastapi/conftest.py @@ -43,7 +43,7 @@ async def charm_file_fixture( charm_file = await ops_test.build_charm(PROJECT_ROOT / "examples/fastapi/charm") elif charm_file[0] != "/": charm_file = PROJECT_ROOT / charm_file - inject_venv(charm_file, PROJECT_ROOT / "paas_app_charmer") + inject_venv(charm_file, PROJECT_ROOT / "src" / "paas_charm") return pathlib.Path(charm_file).absolute() diff --git a/tests/integration/flask/conftest.py b/tests/integration/flask/conftest.py index 33c3e63..6a0280c 100644 --- a/tests/integration/flask/conftest.py +++ b/tests/integration/flask/conftest.py @@ -54,7 +54,7 @@ async def charm_file_fixture(pytestconfig: pytest.Config, ops_test: OpsTest) -> charm_file = await ops_test.build_charm(PROJECT_ROOT / "examples/flask") elif charm_file[0] != "/": charm_file = PROJECT_ROOT / charm_file - inject_venv(charm_file, PROJECT_ROOT / "paas_app_charmer") + inject_venv(charm_file, PROJECT_ROOT / "src" / "paas_charm") return pathlib.Path(charm_file).absolute() diff --git a/tests/integration/go/conftest.py b/tests/integration/go/conftest.py index 1a26671..b7a31db 100644 --- a/tests/integration/go/conftest.py +++ b/tests/integration/go/conftest.py @@ -41,7 +41,7 @@ async def charm_file_fixture( charm_file = await ops_test.build_charm(PROJECT_ROOT / "examples/go/charm") elif charm_file[0] != "/": charm_file = PROJECT_ROOT / charm_file - inject_venv(charm_file, PROJECT_ROOT / "paas_app_charmer") + inject_venv(charm_file, PROJECT_ROOT / "src" / "paas_charm") return pathlib.Path(charm_file).absolute() diff --git a/tests/unit/django/conftest.py b/tests/unit/django/conftest.py index e6ed886..b5e1c3e 100644 --- a/tests/unit/django/conftest.py +++ b/tests/unit/django/conftest.py @@ -14,7 +14,7 @@ from ops.testing import Harness from examples.django.charm.src.charm import DjangoCharm -from paas_app_charmer.database_migration import DatabaseMigrationStatus +from paas_charm.database_migration import DatabaseMigrationStatus from .constants import DEFAULT_LAYER diff --git a/tests/unit/django/test_charm.py b/tests/unit/django/test_charm.py index 2c44bde..bdacdc4 100644 --- a/tests/unit/django/test_charm.py +++ b/tests/unit/django/test_charm.py @@ -13,10 +13,10 @@ from ops.testing import ExecArgs, ExecResult, Harness from examples.django.charm.src.charm import DjangoCharm -from paas_app_charmer._gunicorn.webserver import GunicornWebserver, WebserverConfig -from paas_app_charmer._gunicorn.workload_config import create_workload_config -from paas_app_charmer._gunicorn.wsgi_app import WsgiApp -from paas_app_charmer.charm_state import CharmState +from paas_charm._gunicorn.webserver import GunicornWebserver, WebserverConfig +from paas_charm._gunicorn.workload_config import create_workload_config +from paas_charm._gunicorn.wsgi_app import WsgiApp +from paas_charm.charm_state import CharmState from .constants import DEFAULT_LAYER diff --git a/tests/unit/flask/conftest.py b/tests/unit/flask/conftest.py index 5aa3e1c..604d22f 100644 --- a/tests/unit/flask/conftest.py +++ b/tests/unit/flask/conftest.py @@ -13,7 +13,7 @@ from ops.testing import Harness from examples.flask.src.charm import FlaskCharm -from paas_app_charmer.database_migration import DatabaseMigrationStatus +from paas_charm.database_migration import DatabaseMigrationStatus from .constants import DEFAULT_LAYER, FLASK_CONTAINER_NAME diff --git a/tests/unit/flask/test_charm.py b/tests/unit/flask/test_charm.py index 219e288..4e057e9 100644 --- a/tests/unit/flask/test_charm.py +++ b/tests/unit/flask/test_charm.py @@ -14,12 +14,12 @@ from ops.pebble import ServiceStatus from ops.testing import Harness -from paas_app_charmer._gunicorn.webserver import GunicornWebserver, WebserverConfig -from paas_app_charmer._gunicorn.workload_config import create_workload_config -from paas_app_charmer._gunicorn.wsgi_app import WsgiApp -from paas_app_charmer.charm_state import CharmState -from paas_app_charmer.database_migration import DatabaseMigrationStatus -from paas_app_charmer.flask import Charm +from paas_charm._gunicorn.webserver import GunicornWebserver, WebserverConfig +from paas_charm._gunicorn.workload_config import create_workload_config +from paas_charm._gunicorn.wsgi_app import WsgiApp +from paas_charm.charm_state import CharmState +from paas_charm.database_migration import DatabaseMigrationStatus +from paas_charm.flask import Charm from .constants import ( DEFAULT_LAYER, diff --git a/tests/unit/flask/test_charm_state.py b/tests/unit/flask/test_charm_state.py index 6e46d84..88a5416 100644 --- a/tests/unit/flask/test_charm_state.py +++ b/tests/unit/flask/test_charm_state.py @@ -8,9 +8,9 @@ import pytest -from paas_app_charmer.charm_state import CharmState, S3Parameters -from paas_app_charmer.exceptions import CharmConfigInvalidError -from paas_app_charmer.flask.charm import Charm, FlaskConfig +from paas_charm.charm_state import CharmState, S3Parameters +from paas_charm.exceptions import CharmConfigInvalidError +from paas_charm.flask.charm import Charm, FlaskConfig from .constants import SAML_APP_RELATION_DATA_EXAMPLE diff --git a/tests/unit/flask/test_database_migration.py b/tests/unit/flask/test_database_migration.py index 6990e77..c7e4ab4 100644 --- a/tests/unit/flask/test_database_migration.py +++ b/tests/unit/flask/test_database_migration.py @@ -9,12 +9,12 @@ import pytest from ops.testing import Harness -from paas_app_charmer._gunicorn.webserver import GunicornWebserver, WebserverConfig -from paas_app_charmer._gunicorn.workload_config import create_workload_config -from paas_app_charmer._gunicorn.wsgi_app import WsgiApp -from paas_app_charmer.charm_state import CharmState -from paas_app_charmer.database_migration import DatabaseMigration, DatabaseMigrationStatus -from paas_app_charmer.exceptions import CharmConfigInvalidError +from paas_charm._gunicorn.webserver import GunicornWebserver, WebserverConfig +from paas_charm._gunicorn.workload_config import create_workload_config +from paas_charm._gunicorn.wsgi_app import WsgiApp +from paas_charm.charm_state import CharmState +from paas_charm.database_migration import DatabaseMigration, DatabaseMigrationStatus +from paas_charm.exceptions import CharmConfigInvalidError from .constants import DEFAULT_LAYER, FLASK_CONTAINER_NAME diff --git a/tests/unit/flask/test_databases.py b/tests/unit/flask/test_databases.py index 2aa085e..9b31ceb 100644 --- a/tests/unit/flask/test_databases.py +++ b/tests/unit/flask/test_databases.py @@ -7,7 +7,7 @@ import pytest -from paas_app_charmer.databases import get_uri +from paas_charm.databases import get_uri DATABASE_GET_URI_TEST_PARAMS = [ ( diff --git a/tests/unit/flask/test_flask_app.py b/tests/unit/flask/test_flask_app.py index d296a47..596381c 100644 --- a/tests/unit/flask/test_flask_app.py +++ b/tests/unit/flask/test_flask_app.py @@ -12,11 +12,11 @@ import pytest -from paas_app_charmer._gunicorn.webserver import WebserverConfig -from paas_app_charmer._gunicorn.workload_config import create_workload_config -from paas_app_charmer._gunicorn.wsgi_app import WsgiApp -from paas_app_charmer.app import map_integrations_to_env -from paas_app_charmer.charm_state import CharmState, IntegrationsState, S3Parameters +from paas_charm._gunicorn.webserver import WebserverConfig +from paas_charm._gunicorn.workload_config import create_workload_config +from paas_charm._gunicorn.wsgi_app import WsgiApp +from paas_charm.app import map_integrations_to_env +from paas_charm.charm_state import CharmState, IntegrationsState, S3Parameters @pytest.mark.parametrize( diff --git a/tests/unit/flask/test_webserver.py b/tests/unit/flask/test_webserver.py index cf51bf6..dd54d78 100644 --- a/tests/unit/flask/test_webserver.py +++ b/tests/unit/flask/test_webserver.py @@ -13,11 +13,11 @@ import pytest from ops.testing import Harness -from paas_app_charmer._gunicorn.webserver import GunicornWebserver, WebserverConfig -from paas_app_charmer._gunicorn.workload_config import create_workload_config -from paas_app_charmer._gunicorn.wsgi_app import WsgiApp -from paas_app_charmer.charm_state import CharmState -from paas_app_charmer.utils import enable_pebble_log_forwarding +from paas_charm._gunicorn.webserver import GunicornWebserver, WebserverConfig +from paas_charm._gunicorn.workload_config import create_workload_config +from paas_charm._gunicorn.wsgi_app import WsgiApp +from paas_charm.charm_state import CharmState +from paas_charm.utils import enable_pebble_log_forwarding from .constants import DEFAULT_LAYER, FLASK_CONTAINER_NAME diff --git a/tests/unit/go/test_app.py b/tests/unit/go/test_app.py index 70c0e82..70eaa77 100644 --- a/tests/unit/go/test_app.py +++ b/tests/unit/go/test_app.py @@ -8,9 +8,9 @@ import pytest -from paas_app_charmer.app import App, WorkloadConfig -from paas_app_charmer.charm_state import CharmState, IntegrationsState -from paas_app_charmer.go.charm import GoConfig +from paas_charm.app import App, WorkloadConfig +from paas_charm.charm_state import CharmState, IntegrationsState +from paas_charm.go.charm import GoConfig @pytest.mark.parametrize( diff --git a/tests/unit/test_deprecated.py b/tests/unit/test_deprecated.py new file mode 100644 index 0000000..8a352f8 --- /dev/null +++ b/tests/unit/test_deprecated.py @@ -0,0 +1,23 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + +"""Test deprecated Charm entrypoints.""" + +import paas_app_charmer.django +import paas_app_charmer.fastapi +import paas_app_charmer.flask +import paas_app_charmer.go +import paas_charm.django +import paas_charm.fastapi +import paas_charm.flask +import paas_charm.go + + +def test_deprecated_paths(): + """ + Test that the deprecated classes are subclasses of the correct new entrypoints. + """ + assert issubclass(paas_app_charmer.django.Charm, paas_charm.django.Charm) + assert issubclass(paas_app_charmer.fastapi.Charm, paas_charm.fastapi.Charm) + assert issubclass(paas_app_charmer.flask.Charm, paas_charm.flask.Charm) + assert issubclass(paas_app_charmer.go.Charm, paas_charm.go.Charm) diff --git a/tox.ini b/tox.ini index b15a636..d7adc89 100644 --- a/tox.ini +++ b/tox.ini @@ -7,14 +7,15 @@ envlist = lint, unit, static, coverage-report skip_missing_interpreters = True [vars] -src_path = {toxinidir}/paas_app_charmer/ +src_path = {toxinidir}/src/paas_charm/ +legacy_src_path ={toxinidir}/src/paas_app_charmer/ example_path = {toxinidir}/examples/ tst_path = {toxinidir}/tests/ -all_path = {[vars]src_path} {[vars]example_path} {[vars]tst_path} +all_path = {[vars]src_path} {[vars]example_path} {[vars]tst_path} {[vars]legacy_src_path} [testenv] setenv = - PYTHONPATH={toxinidir}:{toxinidir}/examples/flask/src:{toxinidir}/examples/flask/lib + PYTHONPATH={toxinidir}:{toxinidir}/examples/flask/src:{toxinidir}/examples/flask/lib:{toxinidir}/src PYTHONBREAKPOINT=ipdb.set_trace PY_COLORS=1 passenv = @@ -67,12 +68,12 @@ commands = --skip {toxinidir}/examples/flask/lib \ --skip {toxinidir}/tests/integration/.mypy_cache # pflake8 wrapper supports config from pyproject.toml - pflake8 {[vars]src_path} + pflake8 {[vars]src_path} {[vars]legacy_src_path} isort --check-only --diff {[vars]all_path} black --target-version=py310 --check --diff {[vars]all_path} - mypy {[vars]src_path} - pydocstyle {[vars]src_path} - pylint {[vars]src_path} --min-similarity-lines=10 + mypy {[vars]src_path} {[vars]legacy_src_path} + pydocstyle {[vars]src_path} {[vars]legacy_src_path} + pylint {[vars]src_path} {[vars]legacy_src_path} --min-similarity-lines=10 [testenv:static] description = Run static analysis tests @@ -90,7 +91,7 @@ deps = coverage[toml] -r{toxinidir}/requirements.txt commands = - coverage run --source={[vars]src_path} \ + coverage run --source={[vars]src_path},{[vars]legacy_src_path} \ -m pytest --ignore={[vars]tst_path}integration -v --tb native -s {posargs} coverage report