[keystone-k8s] fix list-ca-certs action result

list-ca-certs action considers part of name as
dictionary key if name contains '.'. This is due
to ops flattening the event result [1].
Replace '.' with '-'

Closes-Bug: #2091691

[1] e573f8f39c/ops/charm.py (L170)

Change-Id: I7f4d22bc978c606496c25187f4892dc47f6472ad
This commit is contained in:
Hemanth Nakkina 2024-12-13 16:33:44 +05:30
parent 8fcfaf96b4
commit 41399f501e
No known key found for this signature in database
GPG Key ID: 2E4970F7B143168E
2 changed files with 12 additions and 1 deletions

View File

@ -105,7 +105,8 @@ actions:
additionalProperties: false
list-ca-certs:
description: |
List CA certs uploaded for transfer
List CA certs uploaded for transfer.
Certificate names with `.` will be replace with `-`.
containers:
keystone:

View File

@ -631,6 +631,16 @@ export OS_AUTH_VERSION=3
self.peers.get_app_data(CERTIFICATE_TRANSFER_LABEL) or "{}"
)
certificates = json.loads(certificates_str)
# Replace '.' in certificate names with '-'
# This is due to the way ops flatten the results dictionary
# https://github.com/canonical/operator/blob/e573f8f39c6b11470dcae3ac94ad798e4655ee91/ops/charm.py#L170
names_with_dot = [k for k, v in certificates.items() if "." in k]
for name in names_with_dot:
name_ = name.replace(".", "-")
certificates[name_] = certificates[name]
certificates.pop(name)
event.set_results(certificates)
def _on_peer_data_changed(self, event: RelationChangedEvent):