[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:
parent
8fcfaf96b4
commit
41399f501e
@ -105,7 +105,8 @@ actions:
|
|||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
list-ca-certs:
|
list-ca-certs:
|
||||||
description: |
|
description: |
|
||||||
List CA certs uploaded for transfer
|
List CA certs uploaded for transfer.
|
||||||
|
Certificate names with `.` will be replace with `-`.
|
||||||
|
|
||||||
containers:
|
containers:
|
||||||
keystone:
|
keystone:
|
||||||
|
@ -631,6 +631,16 @@ export OS_AUTH_VERSION=3
|
|||||||
self.peers.get_app_data(CERTIFICATE_TRANSFER_LABEL) or "{}"
|
self.peers.get_app_data(CERTIFICATE_TRANSFER_LABEL) or "{}"
|
||||||
)
|
)
|
||||||
certificates = json.loads(certificates_str)
|
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)
|
event.set_results(certificates)
|
||||||
|
|
||||||
def _on_peer_data_changed(self, event: RelationChangedEvent):
|
def _on_peer_data_changed(self, event: RelationChangedEvent):
|
||||||
|
Loading…
Reference in New Issue
Block a user