From 3cfd38ac63067fdc447db14b15da4ceefd4def8e Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 18 Sep 2024 10:56:14 +0300 Subject: [PATCH 1/3] deprecate traefik_route --- .../traefik_route_k8s/v0/traefik_route.py | 91 +++++-------------- 1 file changed, 22 insertions(+), 69 deletions(-) diff --git a/lib/charms/traefik_route_k8s/v0/traefik_route.py b/lib/charms/traefik_route_k8s/v0/traefik_route.py index 1822c03..35c4a2b 100644 --- a/lib/charms/traefik_route_k8s/v0/traefik_route.py +++ b/lib/charms/traefik_route_k8s/v0/traefik_route.py @@ -2,75 +2,16 @@ # Copyright 2022 Canonical Ltd. # See LICENSE file for licensing details. -r"""# Interface Library for traefik_route. - -This library wraps relation endpoints for traefik_route. The requirer of this -relation is the traefik-route-k8s charm, or any charm capable of providing -Traefik configuration files. The provider is the traefik-k8s charm, or another -charm willing to consume Traefik configuration files. - -## Getting Started - -To get started using the library, you just need to fetch the library using `charmcraft`. - -```shell -cd some-charm -charmcraft fetch-lib charms.traefik_route_k8s.v0.traefik_route -``` - -To use the library from the provider side (Traefik): - -```yaml -requires: - traefik_route: - interface: traefik_route - limit: 1 -``` - -```python -from charms.traefik_route_k8s.v0.traefik_route import TraefikRouteProvider - -class TraefikCharm(CharmBase): - def __init__(self, *args): - # ... - self.traefik_route = TraefikRouteProvider(self) - - self.framework.observe( - self.traefik_route.on.ready, self._handle_traefik_route_ready - ) - - def _handle_traefik_route_ready(self, event): - config: str = self.traefik_route.get_config(event.relation) # yaml - # use config to configure Traefik -``` - -To use the library from the requirer side (TraefikRoute): - -```yaml -requires: - traefik-route: - interface: traefik_route - limit: 1 - optional: false -``` - -```python -# ... -from charms.traefik_route_k8s.v0.traefik_route import TraefikRouteRequirer - -class TraefikRouteCharm(CharmBase): - def __init__(self, *args): - # ... - traefik_route = TraefikRouteRequirer( - self, self.model.relations.get("traefik-route"), - "traefik-route" - ) - if traefik_route.is_ready(): - traefik_route.submit_to_traefik( - config={'my': {'traefik': 'configuration'}} - ) +r"""# [DEPRECATED!] Interface Library for traefik_route. + +This is a DEPRECATED version of the traefik_route interface library. + +It was dropped and no longer maintained by `traefik-route-k8s-operator`, which will soon be archived. + +traefik_route v0 is now maintained by `traefik-k8s-operator`. + +Please import with `charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route`. -``` """ import logging from typing import Optional @@ -88,7 +29,7 @@ def __init__(self, *args): # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 10 +LIBPATCH = 11 log = logging.getLogger(__name__) @@ -157,6 +98,12 @@ def __init__( external_host: The external host. scheme: The scheme. """ + log.warning( + "The ``traefik_route v0`` library is DEPRECATED " + "and no longer maintained by ``traefik-route-k8s-operator``. " + "``traefik_route v0`` is now maintained by ``traefik-k8s-operator``. " + "Please import with ``charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route``." + ) super().__init__(charm, relation_name) self._stored.set_default(external_host=None, scheme=None) @@ -292,6 +239,12 @@ class TraefikRouteRequirer(Object): _stored = StoredState() def __init__(self, charm: CharmBase, relation: Relation, relation_name: str = "traefik-route"): + log.warning( + "The ``traefik_route v0`` library is DEPRECATED " + "and no longer maintained by ``traefik-route-k8s-operator``. " + "``traefik_route v0`` is now maintained by ``traefik-k8s-operator``. " + "Please import with ``charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route``." + ) super(TraefikRouteRequirer, self).__init__(charm, relation_name) self._stored.set_default(external_host=None, scheme=None) From 8c8ff55f56027eeda08e4b010ccbb50fe86bf1cc Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 18 Sep 2024 11:10:49 +0300 Subject: [PATCH 2/3] improve comment --- lib/charms/traefik_route_k8s/v0/traefik_route.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/charms/traefik_route_k8s/v0/traefik_route.py b/lib/charms/traefik_route_k8s/v0/traefik_route.py index 35c4a2b..602867c 100644 --- a/lib/charms/traefik_route_k8s/v0/traefik_route.py +++ b/lib/charms/traefik_route_k8s/v0/traefik_route.py @@ -6,9 +6,9 @@ This is a DEPRECATED version of the traefik_route interface library. -It was dropped and no longer maintained by `traefik-route-k8s-operator`, which will soon be archived. +It was dropped and no longer maintained under `traefik-route-k8s-operator`, which will soon be archived. -traefik_route v0 is now maintained by `traefik-k8s-operator`. +traefik_route v0 is now maintained under `traefik-k8s-operator`. Please import with `charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route`. @@ -100,8 +100,8 @@ def __init__( """ log.warning( "The ``traefik_route v0`` library is DEPRECATED " - "and no longer maintained by ``traefik-route-k8s-operator``. " - "``traefik_route v0`` is now maintained by ``traefik-k8s-operator``. " + "and no longer maintained under ``traefik-route-k8s-operator``. " + "``traefik_route v0`` is now maintained under ``traefik-k8s-operator``. " "Please import with ``charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route``." ) super().__init__(charm, relation_name) @@ -241,8 +241,8 @@ class TraefikRouteRequirer(Object): def __init__(self, charm: CharmBase, relation: Relation, relation_name: str = "traefik-route"): log.warning( "The ``traefik_route v0`` library is DEPRECATED " - "and no longer maintained by ``traefik-route-k8s-operator``. " - "``traefik_route v0`` is now maintained by ``traefik-k8s-operator``. " + "and no longer maintained under ``traefik-route-k8s-operator``. " + "``traefik_route v0`` is now maintained under ``traefik-k8s-operator``. " "Please import with ``charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route``." ) super(TraefikRouteRequirer, self).__init__(charm, relation_name) From 33bc4f3cfda42fa3fbf886bb6b112b1ad5775ac5 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 18 Sep 2024 16:11:13 +0300 Subject: [PATCH 3/3] rephrase --- lib/charms/traefik_route_k8s/v0/traefik_route.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/charms/traefik_route_k8s/v0/traefik_route.py b/lib/charms/traefik_route_k8s/v0/traefik_route.py index 602867c..5edfcb5 100644 --- a/lib/charms/traefik_route_k8s/v0/traefik_route.py +++ b/lib/charms/traefik_route_k8s/v0/traefik_route.py @@ -10,7 +10,7 @@ traefik_route v0 is now maintained under `traefik-k8s-operator`. -Please import with `charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route`. +Please fetch the new library with `charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route`. """ import logging @@ -102,7 +102,7 @@ def __init__( "The ``traefik_route v0`` library is DEPRECATED " "and no longer maintained under ``traefik-route-k8s-operator``. " "``traefik_route v0`` is now maintained under ``traefik-k8s-operator``. " - "Please import with ``charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route``." + "Please fetch the new library with ``charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route``." ) super().__init__(charm, relation_name) self._stored.set_default(external_host=None, scheme=None) @@ -243,7 +243,7 @@ def __init__(self, charm: CharmBase, relation: Relation, relation_name: str = "t "The ``traefik_route v0`` library is DEPRECATED " "and no longer maintained under ``traefik-route-k8s-operator``. " "``traefik_route v0`` is now maintained under ``traefik-k8s-operator``. " - "Please import with ``charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route``." + "Please fetch the new library with ``charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route``." ) super(TraefikRouteRequirer, self).__init__(charm, relation_name) self._stored.set_default(external_host=None, scheme=None)