Skip to content

Commit

Permalink
address comments #2
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldmitry committed Jul 29, 2024
1 parent 519bdd1 commit a405fd9
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ def __init__(self, *args):
self.framework.observe(self.on.collect_unit_status, self._on_collect_unit_status)

# refuse to handle any other event as we can't possibly know what to do.
if (
not self.coordinator.cluster.has_workers
or not self.coordinator.is_coherent
or not self.coordinator.s3_ready
):
if not self.coordinator.can_handle_events:
# logging will be handled by `self.coordinator` for each of the above circumstances.
return

Expand Down Expand Up @@ -144,11 +140,23 @@ def _external_url(self) -> str:
def _internal_url(self) -> str:
"""Returns workload's FQDN."""
scheme = "http"
if hasattr(self, "coordinator") and self.coordinator.nginx.are_certificates_on_disk:
if self.are_certificates_on_disk:
scheme = "https"

return f"{scheme}://{self.hostname}"

@property
def are_certificates_on_disk(self) -> bool:
"""Return True if the certificates files are on disk."""
nginx_container = self.unit.get_container("nginx")

return (
nginx_container.can_connect()
and nginx_container.exists(CERT_PATH)
and nginx_container.exists(KEY_PATH)
and nginx_container.exists(CA_CERT_PATH)
)

@property
def enabled_receivers(self) -> Set[str]:
"""Extra receivers enabled through config"""
Expand Down

0 comments on commit a405fd9

Please sign in to comment.