Skip to content

Commit

Permalink
Change .chain to hold a str instead of List[str]
Browse files Browse the repository at this point in the history
  • Loading branch information
sed-i committed Mar 26, 2024
1 parent 29b08b1 commit 5511e91
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/charms/observability_libs/v0/cert_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def _generate_csr(
if clear_cert:
self._ca_cert = ""
self._server_cert = ""
self._chain = []
self._chain = ""

def _on_certificate_available(self, event: CertificateAvailableEvent) -> None:
"""Get the certificate from the event and store it in a peer relation.
Expand All @@ -304,7 +304,7 @@ def _on_certificate_available(self, event: CertificateAvailableEvent) -> None:
if event_csr == self._csr:
self._ca_cert = event.ca
self._server_cert = event.certificate
self._chain = event.chain
self._chain = event.chain_as_pem()
self.on.cert_changed.emit() # pyright: ignore

@property
Expand Down Expand Up @@ -375,11 +375,11 @@ def _server_cert(self, value: str):
rel.data[self.charm.unit].update({"certificate": value})

@property
def _chain(self) -> List[str]:
def _chain(self) -> str:
if self._peer_relation:
if chain := self._peer_relation.data[self.charm.unit].get("chain", []):
if chain := self._peer_relation.data[self.charm.unit].get("chain", ""):
return json.loads(cast(str, chain))
return []
return ""

@_chain.setter
def _chain(self, value: List[str]):
Expand All @@ -389,7 +389,7 @@ def _chain(self, value: List[str]):
rel.data[self.charm.unit].update({"chain": json.dumps(value)})

@property
def chain(self) -> List[str]:
def chain(self) -> str:
"""Return the ca chain."""
return self._chain

Expand Down

0 comments on commit 5511e91

Please sign in to comment.