diff --git a/charms/jimm/src/charm.py b/charms/jimm/src/charm.py index 1978ad3fd..1f2a945c1 100755 --- a/charms/jimm/src/charm.py +++ b/charms/jimm/src/charm.py @@ -26,6 +26,7 @@ BlockedStatus, MaintenanceStatus, ModelError, + Relation, WaitingStatus, ) @@ -133,13 +134,7 @@ def _on_config_changed(self, _): dashboard_relation = self.model.get_relation("dashboard") if dashboard_relation: - dashboard_relation.data[self.app].update( - { - "controller-url": "wss://{}".format(self.config["dns-name"]), - "identity-provider-url": self.config["candid-url"], - "is-juju": str(False), - } - ) + self._update_dashboard_relation(dashboard_relation) def _on_leader_elected(self, _): """Update the JIMM configuration that comes from unit @@ -357,7 +352,11 @@ def _snap(self, *args): def _on_dashboard_relation_joined(self, event): if self.model.unit.is_leader(): - event.relation.data[self.app].update( + self._update_dashboard_relation(event.relation) + + def _update_dashboard_relation(self, relation: Relation): + if self.model.unit.is_leader(): + relation.data[self.app].update( { "controller_url": "wss://{}".format(self.config["dns-name"]), "identity_provider_url": self.config["candid-url"],