Skip to content

Commit

Permalink
chore: update charm libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
telcobot committed Jun 12, 2024
1 parent e08a6f4 commit a09d8d5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/charms/lego_base_k8s/v0/lego_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _plugin_config(self):

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


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -144,7 +144,7 @@ def _on_collect_status(self, event: CollectStatusEvent) -> None:
BlockedStatus(err)
)
return
event.add_status(ActiveStatus())
event.add_status(ActiveStatus(self._get_certificate_fulfillment_status()))

def _sync_certificates(self, event: EventBase) -> None:
"""Go through all the certificates relations and handle outstanding requests."""
Expand Down Expand Up @@ -278,6 +278,19 @@ def _generate_signed_certificate(self, csr: str, relation_id: int):
relation_id=relation_id,
)

def _get_certificate_fulfillment_status(self) -> str:
"""Return the status message reflecting how many certificate requests are still pending."""
outstanding_requests_num = len(
self.tls_certificates.get_outstanding_certificate_requests()
)
total_requests_num = len(
self.tls_certificates.get_requirer_csrs()
)
fulfilled_certs = total_requests_num - outstanding_requests_num
return (
f"{fulfilled_certs}/{total_requests_num} certificate requests are fulfilled"
)

@property
def _cmd(self) -> List[str]:
"""Command to run to get the certificate.
Expand Down

0 comments on commit a09d8d5

Please sign in to comment.