Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update charm libraries #168

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading