Skip to content

Commit

Permalink
chore: Update charm libraries (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
telcobot committed May 28, 2024
1 parent 584d074 commit a043036
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/charms/tls_certificates_interface/v3/tls_certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def _on_all_certificates_invalidated(self, event: AllCertificatesInvalidatedEven

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

PYDEPS = ["cryptography", "jsonschema"]

Expand Down Expand Up @@ -1874,6 +1874,9 @@ def _on_relation_changed(self, event: RelationChangedEvent) -> None:
if certificate.csr in requirer_csrs:
if certificate.revoked:
with suppress(SecretNotFoundError):
logger.debug(
"Removing secret with label %s", f"{LIBID}-{certificate.csr}"
)
secret = self.model.get_secret(label=f"{LIBID}-{certificate.csr}")
secret.remove_all_revisions()
self.on.certificate_invalidated.emit(
Expand All @@ -1885,13 +1888,18 @@ def _on_relation_changed(self, event: RelationChangedEvent) -> None:
)
else:
try:
logger.debug(
"Setting secret with label %s", f"{LIBID}-{certificate.csr}"
)
secret = self.model.get_secret(label=f"{LIBID}-{certificate.csr}")
secret.set_content({"certificate": certificate.certificate})
secret.set_info(
expire=self._get_next_secret_expiry_time(certificate),
)
except SecretNotFoundError:
logger.debug("Adding secret with label %s", f"{LIBID}-{certificate.csr}")
logger.debug(
"Creating new secret with label %s", f"{LIBID}-{certificate.csr}"
)
secret = self.charm.unit.add_secret(
{"certificate": certificate.certificate},
label=f"{LIBID}-{certificate.csr}",
Expand Down

0 comments on commit a043036

Please sign in to comment.