Skip to content

Commit

Permalink
Merge pull request #12 from alesstimec/openfga-relation-interface-upd…
Browse files Browse the repository at this point in the history
…ate-01

Openfga relation interface update 01
  • Loading branch information
alesstimec authored Jun 27, 2023
2 parents c63d6e7 + e42aed7 commit 3d59d19
Show file tree
Hide file tree
Showing 13 changed files with 488 additions and 570 deletions.
1 change: 1 addition & 0 deletions .github/workflows/charm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
with:
provider: microk8s
microk8s-addons: "storage dns rbac registry"
juju-channel: 3.2/stable
- name: Create local OCI images
run: cd .. && make push-images-microk8s
- name: Run integration tests
Expand Down
2 changes: 1 addition & 1 deletion charms/openfga-k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This repository contains a [Juju Charm](https://charmhub.io/openfga-k8s) for dep

## Usage

Bootstrap a [microk8s controller](https://juju.is/docs/olm/microk8s) using juju `3.1` and create a new Juju model:
Bootstrap a [microk8s controller](https://juju.is/docs/olm/microk8s) using juju `3.2` and create a new Juju model:

```shell
juju add-model openfga
Expand Down
15 changes: 11 additions & 4 deletions charms/openfga-k8s/lib/charms/openfga_k8s/v0/openfga.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ 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 @@ -71,7 +76,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 = 2
LIBPATCH = 3

logger = logging.getLogger(__name__)

Expand All @@ -86,8 +91,8 @@ def store_id(self):
return self.relation.data[self.relation.app].get("store_id")

@property
def token(self):
return self.relation.data[self.relation.app].get("token")
def token_secret_id(self):
return self.relation.data[self.relation.app].get("token_secret_id")

@property
def address(self):
Expand Down Expand Up @@ -149,5 +154,7 @@ 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/openfga-k8s/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ description: |
Community section for third-party SDKs and tools.
peers:
openfga-peer:
peer:
interface: openfga-peer

provides:
Expand Down
2 changes: 1 addition & 1 deletion charms/openfga-k8s/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ops >= 1.5.2
ops >= 2.3.0
requests >= 2.25.1
jsonschema >= 3.2.0
cryptography >= 3.4.8
Expand Down
Loading

0 comments on commit 3d59d19

Please sign in to comment.