Skip to content

Commit

Permalink
Reverted to the previous revision of the openfga relation library.
Browse files Browse the repository at this point in the history
  • Loading branch information
alesstimec committed Jun 29, 2023
1 parent c4bdccc commit a92b950
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 32 deletions.
15 changes: 4 additions & 11 deletions charms/jimm-k8s/lib/charms/openfga_k8s/v0/openfga.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
```
"""
Expand All @@ -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__)

Expand All @@ -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):
Expand Down Expand Up @@ -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
)
6 changes: 3 additions & 3 deletions charms/jimm-k8s/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 4 additions & 11 deletions charms/jimm/lib/charms/openfga_k8s/v0/openfga.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
```
"""
Expand All @@ -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__)

Expand All @@ -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):
Expand Down Expand Up @@ -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
)
2 changes: 1 addition & 1 deletion charms/jimm/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-r requirements.txt
coverage
flake8
flake8
10 changes: 5 additions & 5 deletions charms/jimm/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion charms/jimm/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ commands =
description = Run integration tests
deps =
pytest
juju
juju~=3.2
pytest-operator
-r{toxinidir}/requirements.txt
commands =
Expand Down

0 comments on commit a92b950

Please sign in to comment.