Skip to content

Commit

Permalink
chore: update charm libraries (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
observability-noctua-bot authored Jun 13, 2024
1 parent ca0d2cb commit 304f137
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions lib/charms/observability_libs/v1/cert_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

LIBID = "b5cd5cd580f3428fa5f59a8876dcbe6a"
LIBAPI = 1
LIBPATCH = 8
LIBPATCH = 9

VAULT_SECRET_LABEL = "cert-handler-private-vault"

Expand Down Expand Up @@ -391,30 +391,37 @@ def _migrate_vault(self):

@property
def enabled(self) -> bool:
"""Boolean indicating whether the charm has a tls_certificates relation."""
"""Boolean indicating whether the charm has a tls_certificates relation.
See also the `available` property.
"""
# We need to check for units as a temporary workaround because of https://bugs.launchpad.net/juju/+bug/2024583
# This could in theory not work correctly on scale down to 0 but it is necessary for the moment.

if not self.charm.model.get_relation(self.certificates_relation_name):
if not self.relation:
return False

if not self.charm.model.get_relation(
self.certificates_relation_name
).units: # pyright: ignore
if not self.relation.units: # pyright: ignore
return False

if not self.charm.model.get_relation(
self.certificates_relation_name
).app: # pyright: ignore
if not self.relation.app: # pyright: ignore
return False

if not self.charm.model.get_relation(
self.certificates_relation_name
).data: # pyright: ignore
if not self.relation.data: # pyright: ignore
return False

return True

@property
def available(self) -> bool:
"""Return True if all certs are available in relation data; False otherwise."""
return (
self.enabled
and self.server_cert is not None
and self.private_key is not None
and self.ca_cert is not None
)

def _on_certificates_relation_joined(self, _) -> None:
# this will only generate a csr if we don't have one already
self._generate_csr()
Expand Down

0 comments on commit 304f137

Please sign in to comment.