Skip to content

Commit

Permalink
Update charm libs
Browse files Browse the repository at this point in the history
  • Loading branch information
canonical-iam committed Jan 13, 2025
1 parent 610ac20 commit 7c7bc9b
Show file tree
Hide file tree
Showing 8 changed files with 1,956 additions and 1,870 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ def _on_certificate_removed(self, event: CertificateRemovedEvent):
"""


import json
import logging
from typing import List, Mapping

from jsonschema import exceptions, validate # type: ignore[import-untyped]
from ops import Relation
from ops.charm import CharmBase, CharmEvents, RelationBrokenEvent, RelationChangedEvent
from ops.framework import EventBase, EventSource, Handle, Object

Expand All @@ -113,7 +113,7 @@ def _on_certificate_removed(self, event: CertificateRemovedEvent):

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

PYDEPS = ["jsonschema"]

Expand Down Expand Up @@ -392,3 +392,11 @@ def _on_relation_broken(self, event: RelationBrokenEvent) -> None:
None
"""
self.on.certificate_removed.emit(relation_id=event.relation.id)

def is_ready(self, relation: Relation) -> bool:
"""Check if the relation is ready by checking that it has valid relation data."""
relation_data = _load_relation_data(relation.data[relation.app])
if not self._relation_data_is_valid(relation_data):
logger.warning("Provider relation data did not pass JSON Schema validation: ")
return False
return True
Loading

0 comments on commit 7c7bc9b

Please sign in to comment.