Skip to content

Commit

Permalink
Merge pull request #89 from canonical/IAM-1281
Browse files Browse the repository at this point in the history
fix: fix the ldap requested event initialization
  • Loading branch information
wood-push-melon authored Jan 15, 2025
2 parents 9c78ee2 + 76fe8c3 commit 356c6eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/charms/glauth_k8s/v0/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _on_ldap_requested(self, event: LdapRequestedEvent) -> None:
RelationCreatedEvent,
RelationEvent,
)
from ops.framework import EventSource, Object, ObjectEvents
from ops.framework import EventSource, Handle, Object, ObjectEvents
from ops.model import Relation, SecretNotFoundError
from pydantic import (
BaseModel,
Expand All @@ -155,7 +155,7 @@ def _on_ldap_requested(self, event: LdapRequestedEvent) -> None:

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

PYDEPS = ["pydantic>=2.5.3"]

Expand Down Expand Up @@ -280,6 +280,9 @@ class LdapRequirerData(BaseModel):
class LdapRequestedEvent(RelationEvent):
"""An event emitted when the LDAP integration is built."""

def __init__(self, handle: Handle, relation: Relation) -> None:
super().__init__(handle, relation, relation.app)

@property
def data(self) -> Optional[LdapRequirerData]:
relation_data = self.relation.data.get(self.relation.app)
Expand Down
4 changes: 2 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointProvider
from charms.traefik_k8s.v1.ingress_per_unit import IngressPerUnitRequirer
from lightkube import Client
from ops import main
from ops.charm import (
CharmBase,
ConfigChangedEvent,
Expand All @@ -37,7 +38,6 @@
RelationJoinedEvent,
RemoveEvent,
)
from ops.main import main
from ops.model import ActiveStatus, BlockedStatus, MaintenanceStatus
from ops.pebble import ChangeError

Expand Down Expand Up @@ -276,7 +276,7 @@ def __on_pebble_ready(self, event: PebbleReadyEvent) -> None:
@wait_when(database_not_ready, service_not_ready)
def _on_ldap_requested(self, event: LdapRequestedEvent) -> None:
if not (requirer_data := event.data):
logger.error(f"The LDAP requirer {event.app.name} does not provide necessary data.")
logger.warning(f"The LDAP requirer {event.app.name} does not provide necessary data.")
return

self._ldap_integration.load_bind_account(
Expand Down

0 comments on commit 356c6eb

Please sign in to comment.