From a92b950f74f6d46f9049fef317238cbf68d52a55 Mon Sep 17 00:00:00 2001 From: alesstimec Date: Thu, 29 Jun 2023 12:04:24 +0200 Subject: [PATCH] Reverted to the previous revision of the openfga relation library. --- .../jimm-k8s/lib/charms/openfga_k8s/v0/openfga.py | 15 ++++----------- charms/jimm-k8s/src/charm.py | 6 +++--- charms/jimm/lib/charms/openfga_k8s/v0/openfga.py | 15 ++++----------- charms/jimm/requirements-dev.txt | 2 +- charms/jimm/src/charm.py | 10 +++++----- charms/jimm/tox.ini | 2 +- 6 files changed, 18 insertions(+), 32 deletions(-) diff --git a/charms/jimm-k8s/lib/charms/openfga_k8s/v0/openfga.py b/charms/jimm-k8s/lib/charms/openfga_k8s/v0/openfga.py index 8160715ce..f72189656 100644 --- a/charms/jimm-k8s/lib/charms/openfga_k8s/v0/openfga.py +++ b/charms/jimm-k8s/lib/charms/openfga_k8s/v0/openfga.py @@ -49,11 +49,6 @@ def _on_openfga_store_created(self, event: OpenFGAStoreCreateEvent): logger.info("address {}".format(event.address)) logger.info("port {}".format(event.port)) logger.info("scheme {}".format(event.scheme)) - - if event.token_secret_id: - secret = self.model.get_secret(id=event.token_secret_id) - content = secret.get_content() - # and get the token with content["token"] ``` """ @@ -76,7 +71,7 @@ def _on_openfga_store_created(self, event: OpenFGAStoreCreateEvent): # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 3 +LIBPATCH = 2 logger = logging.getLogger(__name__) @@ -91,8 +86,8 @@ def store_id(self): return self.relation.data[self.relation.app].get("store_id") @property - def token_secret_id(self): - return self.relation.data[self.relation.app].get("token_secret_id") + def token(self): + return self.relation.data[self.relation.app].get("token") @property def address(self): @@ -154,7 +149,5 @@ def _on_relation_changed(self, event: RelationChangedEvent): """Handle the relation-changed event.""" if self.model.unit.is_leader(): self.on.openfga_store_created.emit( - event.relation, - app=event.app, - unit=event.unit, + event.relation, app=event.app, unit=event.unit ) diff --git a/charms/jimm-k8s/src/charm.py b/charms/jimm-k8s/src/charm.py index 05c54162a..ff4c844a1 100755 --- a/charms/jimm-k8s/src/charm.py +++ b/charms/jimm-k8s/src/charm.py @@ -568,11 +568,11 @@ def _on_openfga_store_created(self, event: OpenFGAStoreCreateEvent): if not event.store_id: return - secret = self.model.get_secret(id=event.token_secret_id) - secret_content = secret.get_content() + # secret = self.model.get_secret(id=event.token_secret_id) + # secret_content = secret.get_content() self._state.openfga_store_id = event.store_id - self._state.openfga_token = secret_content["token"] + self._state.openfga_token = event.token # secret_content["token"] self._state.openfga_address = event.address self._state.openfga_port = event.port self._state.openfga_scheme = event.scheme diff --git a/charms/jimm/lib/charms/openfga_k8s/v0/openfga.py b/charms/jimm/lib/charms/openfga_k8s/v0/openfga.py index 8160715ce..f72189656 100644 --- a/charms/jimm/lib/charms/openfga_k8s/v0/openfga.py +++ b/charms/jimm/lib/charms/openfga_k8s/v0/openfga.py @@ -49,11 +49,6 @@ def _on_openfga_store_created(self, event: OpenFGAStoreCreateEvent): logger.info("address {}".format(event.address)) logger.info("port {}".format(event.port)) logger.info("scheme {}".format(event.scheme)) - - if event.token_secret_id: - secret = self.model.get_secret(id=event.token_secret_id) - content = secret.get_content() - # and get the token with content["token"] ``` """ @@ -76,7 +71,7 @@ def _on_openfga_store_created(self, event: OpenFGAStoreCreateEvent): # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 3 +LIBPATCH = 2 logger = logging.getLogger(__name__) @@ -91,8 +86,8 @@ def store_id(self): return self.relation.data[self.relation.app].get("store_id") @property - def token_secret_id(self): - return self.relation.data[self.relation.app].get("token_secret_id") + def token(self): + return self.relation.data[self.relation.app].get("token") @property def address(self): @@ -154,7 +149,5 @@ def _on_relation_changed(self, event: RelationChangedEvent): """Handle the relation-changed event.""" if self.model.unit.is_leader(): self.on.openfga_store_created.emit( - event.relation, - app=event.app, - unit=event.unit, + event.relation, app=event.app, unit=event.unit ) diff --git a/charms/jimm/requirements-dev.txt b/charms/jimm/requirements-dev.txt index 4f2a3f5bc..9d03b1b37 100644 --- a/charms/jimm/requirements-dev.txt +++ b/charms/jimm/requirements-dev.txt @@ -1,3 +1,3 @@ -r requirements.txt coverage -flake8 +flake8 \ No newline at end of file diff --git a/charms/jimm/src/charm.py b/charms/jimm/src/charm.py index 69d8436d6..248b951d1 100755 --- a/charms/jimm/src/charm.py +++ b/charms/jimm/src/charm.py @@ -408,16 +408,16 @@ def _on_dashboard_relation_joined(self, event): def _on_openfga_store_created(self, event: OpenFGAStoreCreateEvent): if not event.store_id: return - - secret = self.model.get_secret(id=event.token_secret_id) - secret_content = secret.get_content() - + + # secret = self.model.get_secret(id=event.token_secret_id) + # secret_content = secret.get_content() + args = { "openfga_host": event.address, "openfga_port": event.port, "openfga_scheme": event.scheme, "openfga_store": event.store_id, - "openfga_token": secret_content["token"], + "openfga_token": event.token # secret_content["token"], } with open(self._env_filename("openfga"), "wt") as f: diff --git a/charms/jimm/tox.ini b/charms/jimm/tox.ini index 839a448c7..eb08ed4aa 100644 --- a/charms/jimm/tox.ini +++ b/charms/jimm/tox.ini @@ -62,7 +62,7 @@ commands = description = Run integration tests deps = pytest - juju + juju~=3.2 pytest-operator -r{toxinidir}/requirements.txt commands =