Skip to content
New issue

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

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

Already on GitHub? # to your account

Updated hydra_endpoints relation name #105

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/charms/hydra/v0/hydra_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
In the `metadata.yaml` of the charm, add the following:
```yaml
requires:
endpoint-info:
hydra-endpoint-info:
interface: hydra_endpoints
limit: 1
```
Expand Down Expand Up @@ -52,9 +52,9 @@ def some_event_function():

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 4
LIBPATCH = 5

RELATION_NAME = "endpoint-info"
RELATION_NAME = "hydra-endpoint-info"
INTERFACE_NAME = "hydra_endpoints"
logger = logging.getLogger(__name__)

Expand All @@ -70,7 +70,7 @@ class HydraEndpointsProviderEvents(ObjectEvents):


class HydraEndpointsProvider(Object):
"""Provider side of the endpoint-info relation."""
"""Provider side of the hydra-endpoint-info relation."""

on = HydraEndpointsProviderEvents()

Expand All @@ -93,7 +93,7 @@ def send_endpoint_relation_data(self, admin_endpoint: str, public_endpoint: str)
if not self._charm.unit.is_leader():
return

relations = self.model.relations[RELATION_NAME]
relations = self.model.relations[self._relation_name]
for relation in relations:
relation.data[self._charm.app].update(
{
Expand All @@ -113,7 +113,7 @@ class HydraEndpointsRelationMissingError(HydraEndpointsRelationError):
"""Raised when the relation is missing."""

def __init__(self) -> None:
self.message = "Missing endpoint-info relation with hydra"
self.message = "Missing hydra-endpoint-info relation with hydra"
super().__init__(self.message)


Expand All @@ -126,7 +126,7 @@ def __init__(self, message: str) -> None:


class HydraEndpointsRequirer(Object):
"""Requirer side of the endpoint-info relation."""
"""Requirer side of the hydra-endpoint-info relation."""

def __init__(self, charm: CharmBase, relation_name: str = RELATION_NAME) -> None:
super().__init__(charm, relation_name)
Expand All @@ -143,7 +143,7 @@ def get_hydra_endpoints(self) -> Dict:

if "admin_endpoint" not in data:
raise HydraEndpointsRelationDataMissingError(
"Missing admin endpoint in endpoint-info relation data"
"Missing admin endpoint in hydra-endpoint-info relation data"
)

return {
Expand Down
2 changes: 1 addition & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ requires:
description: |
Provides traces to COS Tempo instance
provides:
endpoint-info:
hydra-endpoint-info:
interface: hydra_endpoints
description: |
Provides API endpoints to a related application
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,15 @@ def test_hydra_endpoint_info_relation_data_without_ingress_relation_data(harness
admin_ingress_relation_id = harness.add_relation("admin-ingress", "admin-traefik")
harness.add_relation_unit(admin_ingress_relation_id, "admin-traefik/0")

endpoint_info_relation_id = harness.add_relation("endpoint-info", "kratos")
harness.add_relation_unit(endpoint_info_relation_id, "kratos/0")
hydra_endpoint_info_relation_id = harness.add_relation("hydra-endpoint-info", "kratos")
harness.add_relation_unit(hydra_endpoint_info_relation_id, "kratos/0")

expected_data = {
"admin_endpoint": "http://hydra.testing.svc.cluster.local:4445",
"public_endpoint": "http://hydra.testing.svc.cluster.local:4444",
}

assert harness.get_relation_data(endpoint_info_relation_id, "hydra") == expected_data
assert harness.get_relation_data(hydra_endpoint_info_relation_id, "hydra") == expected_data


def test_provider_info_in_databag_when_ingress_then_oauth_relation(
Expand Down