Skip to content

Commit

Permalink
Doc fix; *-arg consistency between provider and requirer (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
sed-i authored Sep 27, 2023
1 parent 7e95796 commit 36dc399
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/charms/alertmanager_k8s/v1/alertmanager_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
```python
# ...
from charms.alertmanager_k8s.v0.alertmanager_dispatch import AlertmanagerConsumer
from charms.alertmanager_k8s.v1.alertmanager_dispatch import AlertmanagerConsumer
class SomeApplication(CharmBase):
def __init__(self, *args):
Expand All @@ -42,7 +42,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 = 0
LIBPATCH = 1

PYDEPS = ["pydantic"]

Expand Down Expand Up @@ -149,7 +149,7 @@ class AlertmanagerConsumer(RelationManagerBase):
A typical example of importing this library might be
```python
from charms.alertmanager_k8s.v0.alertmanager_dispatch import AlertmanagerConsumer
from charms.alertmanager_k8s.v1.alertmanager_dispatch import AlertmanagerConsumer
```
In your charm's `__init__` method:
Expand Down Expand Up @@ -180,7 +180,7 @@ class AlertmanagerConsumer(RelationManagerBase):

on = AlertmanagerConsumerEvents() # pyright: ignore

def __init__(self, charm: CharmBase, relation_name: str = "alerting"):
def __init__(self, charm: CharmBase, *, relation_name: str = "alerting"):
super().__init__(charm, relation_name, RelationRole.requires)

self.framework.observe(
Expand Down Expand Up @@ -272,19 +272,21 @@ class AlertmanagerProvider(RelationManagerBase):
A typical example of importing this library might be
```python
from charms.alertmanager_k8s.v0.alertmanager_dispatch import AlertmanagerProvider
from charms.alertmanager_k8s.v1.alertmanager_dispatch import AlertmanagerProvider
```
In your charm's `__init__` method:
```python
self.alertmanager_provider = AlertmanagerProvider(self, self._relation_name, self._api_port)
self.alertmanager_provider = AlertmanagerProvider(
self, relation_name=self._relation_name, external_url=f"http://{socket.getfqdn()}:9093"
)
```
Then inform consumers on any update to alertmanager cluster data via
```python
self.alertmanager_provider.update_relation_data()
self.alertmanager_provider.update(external_url=self.ingress.url)
```
This provider auto-registers relation events on behalf of the main Alertmanager charm.
Expand Down

0 comments on commit 36dc399

Please sign in to comment.