Skip to content

Commit

Permalink
publish traefik_route lib
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldmitry committed Sep 18, 2024
1 parent d16fee2 commit a7c4785
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
```shell
cd some-charm
charmcraft fetch-lib charms.traefik_route_k8s.v0.traefik_route
charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route
```
To use the library from the provider side (Traefik):
Expand All @@ -28,7 +28,7 @@
```
```python
from charms.traefik_route_k8s.v0.traefik_route import TraefikRouteProvider
from charms.traefik_k8s.v0.traefik_route import TraefikRouteProvider
class TraefikCharm(CharmBase):
def __init__(self, *args):
Expand Down Expand Up @@ -56,7 +56,7 @@ def _handle_traefik_route_ready(self, event):
```python
# ...
from charms.traefik_route_k8s.v0.traefik_route import TraefikRouteRequirer
from charms.traefik_k8s.v0.traefik_route import TraefikRouteRequirer
class TraefikRouteCharm(CharmBase):
def __init__(self, *args):
Expand Down Expand Up @@ -88,7 +88,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 = 1

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -254,8 +254,10 @@ def is_ready(self, relation: Relation) -> bool:

def get_config(self, relation: Relation) -> Optional[str]:
"""Renamed to ``get_dynamic_config``."""
log.warning("``TraefikRouteProvider.get_config`` is deprecated. "
"Use ``TraefikRouteProvider.get_dynamic_config`` instead")
log.warning(
"``TraefikRouteProvider.get_config`` is deprecated. "
"Use ``TraefikRouteProvider.get_dynamic_config`` instead"
)
return self.get_dynamic_config(relation)

def get_dynamic_config(self, relation: Relation) -> Optional[str]:
Expand Down Expand Up @@ -356,7 +358,7 @@ def is_ready(self) -> bool:
"""Is the TraefikRouteRequirer ready to submit data to Traefik?"""
return self._relation is not None

def submit_to_traefik(self, config: dict, static: dict=None):
def submit_to_traefik(self, config: dict, static: Optional[dict] = None):
"""Relay an ingress configuration data structure to traefik.
This will publish to the traefik-route relation databag
Expand Down
8 changes: 4 additions & 4 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@
from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointProvider
from charms.tempo_k8s.v1.charm_tracing import trace_charm
from charms.tempo_k8s.v2.tracing import TracingEndpointRequirer
from charms.traefik_k8s.v0.traefik_route import (
TraefikRouteProvider,
TraefikRouteRequirerReadyEvent,
)
from charms.traefik_k8s.v1.ingress import IngressPerAppProvider as IPAv1
from charms.traefik_k8s.v1.ingress_per_unit import (
DataValidationError,
IngressPerUnitProvider,
)
from charms.traefik_k8s.v2.ingress import IngressPerAppProvider as IPAv2
from charms.traefik_route_k8s.v0.traefik_route import (
TraefikRouteProvider,
TraefikRouteRequirerReadyEvent,
)
from deepmerge import always_merger
from lightkube.core.client import Client
from lightkube.core.exceptions import ApiError
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def copy_traefik_library_into_tester_charms(ops_test):
"traefik_k8s/v2/ingress.py",
"traefik_k8s/v1/ingress_per_unit.py",
"observability_libs/v1/kubernetes_service_patch.py",
"traefik_route_k8s/v0/traefik_route.py",
"traefik_k8s/v0/traefik_route.py",
]
for tester in ["forward-auth", "ipa", "ipu", "tcp", "route"]:
for lib in libraries:
Expand Down
4 changes: 1 addition & 3 deletions tests/integration/spellbook/build_all_caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def main():
spellbook_fetch(
charm_name="route-tester",
charm_root=testers_root / "route",
pull_libs=[
traefik_root / "lib" / "charms" / "traefik_route_k8s" / "v0" / "traefik_route.py"
],
pull_libs=[traefik_root / "lib" / "charms" / "traefik_k8s" / "v0" / "traefik_route.py"],
)
spellbook_fetch(
charm_name="ipa-tester",
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/testers/route/src/charm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
from charms.traefik_route_k8s.v0.traefik_route import TraefikRouteRequirer
from charms.traefik_k8s.v0.traefik_route import TraefikRouteRequirer
from ops.charm import CharmBase
from ops.model import ActiveStatus

Expand Down

0 comments on commit a7c4785

Please sign in to comment.