From 4a887639a8206c4e5b2f43a0486d2730cdfc64cc Mon Sep 17 00:00:00 2001 From: Nikos Date: Fri, 2 Aug 2024 16:52:10 +0300 Subject: [PATCH 1/2] refactor: migrate to charmcraft.yaml --- README.md | 2 +- actions.yaml | 7 --- charmcraft.yaml | 79 ++++++++++++++++++++++++++++++- config.yaml | 8 ---- integration-requirements.txt | 2 +- metadata.yaml | 54 --------------------- tests/integration/test_charm.py | 2 +- tests/integration/test_upgrade.py | 2 +- 8 files changed, 82 insertions(+), 74 deletions(-) delete mode 100644 actions.yaml delete mode 100644 config.yaml delete mode 100644 metadata.yaml diff --git a/README.md b/README.md index d6ef79e..a3af20e 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ juju integrate postgresql-k8s:database openfga-k8s #### `openfga` interface Current charm provides a library for the `openfga` integration interface. Your -application should define an interface in `metadata.yaml`: +application should define an interface in `charmcraft.yaml`: ```yaml requires: diff --git a/actions.yaml b/actions.yaml deleted file mode 100644 index d08d374..0000000 --- a/actions.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright 2022 Canonical -# See LICENSE file for licensing details. -# -# Learn more about actions at: https://juju.is/docs/sdk/actions - -schema-upgrade: - description: Upgrade the application database schema. diff --git a/charmcraft.yaml b/charmcraft.yaml index 4569162..c491a84 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -1,10 +1,86 @@ # This file configures Charmcraft. # See https://juju.is/docs/sdk/charmcraft-config for guidance. +name: openfga-k8s type: charm +title: OpenFGA +summary: A high-performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. +description: | + A high-performance and flexible authorization/permission engine + built for developers and inspired by Google Zanzibar. + + OpenFGA is designed to make it easy for developers to model + their application permissions and add and integrate fine-grained + authorization into their applications. + + It allows in-memory data storage for quick development, as well + as pluggable database modules. It currently supports PostgreSQL + and MySQL. + + It offers an HTTP API and a gRPC API. It has SDKs for + Node.js/JavaScript, GoLang, Python and .NET. Look in our + Community section for third-party SDKs and tools. + +links: + documentation: https://discourse.charmhub.io/t/openfga-k8s-docs-index/13826 + website: https://github.com/canonical/openfga-operator + source: https://github.com/canonical/openfga-operator + issues: https://github.com/canonical/openfga-operator/issues + +peers: + peer: + interface: openfga-peer + +provides: + openfga: + interface: openfga + grafana-dashboard: + interface: grafana_dashboard + metrics-endpoint: + interface: prometheus_scrape + +requires: + http-ingress: + interface: ingress + limit: 1 + grpc-ingress: + interface: ingress + limit: 1 + database: + interface: postgresql_client + limit: 1 + log-proxy: + interface: loki_push_api + optional: true + limit: 1 + +containers: + openfga: + resource: oci-image + +resources: + oci-image: + type: oci-image + description: OCI image for OpenFGA + upstream-source: ghcr.io/canonical/openfga:1.5.2 + +config: + options: + log-level: + description: | + Configures the log level of gunicorn. + + Acceptable values are: "info", "debug", "warning", "error" and "critical" + default: "info" + type: string + +actions: + schema-upgrade: + description: Upgrade the application database schema. + parts: charm: - charm-python-packages: + charm-python-packages: - setuptools charm-binary-python-packages: - requests >= 2.25.1 @@ -12,6 +88,7 @@ parts: - cryptography >= 3.4.8 - lightkube - lightkube-models + bases: - build-on: - name: ubuntu diff --git a/config.yaml b/config.yaml deleted file mode 100644 index 263ae4b..0000000 --- a/config.yaml +++ /dev/null @@ -1,8 +0,0 @@ -options: - log-level: - description: | - Configures the log level of gunicorn. - - Acceptable values are: "info", "debug", "warning", "error" and "critical" - default: "info" - type: string diff --git a/integration-requirements.txt b/integration-requirements.txt index e65e2a5..4d99b4b 100644 --- a/integration-requirements.txt +++ b/integration-requirements.txt @@ -1,4 +1,4 @@ pytest juju -pytest-operator==0.31.1 +pytest-operator==0.35.0 -r requirements.txt diff --git a/metadata.yaml b/metadata.yaml deleted file mode 100644 index ed42771..0000000 --- a/metadata.yaml +++ /dev/null @@ -1,54 +0,0 @@ -name: openfga-k8s -display-name: OpenFGA -summary: A high-performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar. -docs: https://discourse.charmhub.io/t/openfga-k8s-docs-index/13826 -website: https://github.com/canonical/openfga-operator -source: https://github.com/canonical/openfga-operator -issues: https://github.com/canonical/openfga-operator/issues -description: | - A high-performance and flexible authorization/permission engine - built for developers and inspired by Google Zanzibar. - - OpenFGA is designed to make it easy for developers to model - their application permissions and add and integrate fine-grained - authorization into their applications. - - It allows in-memory data storage for quick development, as well - as pluggable database modules. It currently supports PostgreSQL - and MySQL. - - It offers an HTTP API and a gRPC API. It has SDKs for - Node.js/JavaScript, GoLang, Python and .NET. Look in our - Community section for third-party SDKs and tools. -peers: - peer: - interface: openfga-peer -provides: - openfga: - interface: openfga - grafana-dashboard: - interface: grafana_dashboard - metrics-endpoint: - interface: prometheus_scrape -requires: - http-ingress: - interface: ingress - limit: 1 - grpc-ingress: - interface: ingress - limit: 1 - database: - interface: postgresql_client - limit: 1 - log-proxy: - interface: loki_push_api - optional: true - limit: 1 -containers: - openfga: - resource: oci-image -resources: - oci-image: - type: oci-image - description: OCI image for OpenFGA - upstream-source: ghcr.io/canonical/openfga:1.5.2 diff --git a/tests/integration/test_charm.py b/tests/integration/test_charm.py index 12cb7ad..b5b25c4 100644 --- a/tests/integration/test_charm.py +++ b/tests/integration/test_charm.py @@ -13,7 +13,7 @@ logger = logging.getLogger(__name__) -METADATA = yaml.safe_load(Path("./metadata.yaml").read_text()) +METADATA = yaml.safe_load(Path("./charmcraft.yaml").read_text()) OPENFGA_APP = "openfga" TRAEFIK_CHARM = "traefik-k8s" TRAEFIK_GRPC_APP = "traefik-grpc" diff --git a/tests/integration/test_upgrade.py b/tests/integration/test_upgrade.py index e2307cd..1860d29 100644 --- a/tests/integration/test_upgrade.py +++ b/tests/integration/test_upgrade.py @@ -13,7 +13,7 @@ logger = logging.getLogger(__name__) -METADATA = yaml.safe_load(Path("./metadata.yaml").read_text()) +METADATA = yaml.safe_load(Path("./charmcraft.yaml").read_text()) APP_NAME = "openfga" From 9ee8459089c4ab376a3575c93ee193d670557651 Mon Sep 17 00:00:00 2001 From: Nikos Date: Mon, 5 Aug 2024 10:30:45 +0300 Subject: [PATCH 2/2] fix: unpin lightkube-models --- .github/workflows/tests.yaml | 3 +-- requirements.txt | 1 - tests/integration/test_charm.py | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c66354e..69fd135 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -32,8 +32,7 @@ jobs: with: provider: microk8s channel: 1.28-strict/stable - juju-channel: 3.2 - bootstrap-options: '--agent-version=3.2.0' + juju-channel: 3.4 lxd-channel: 5.20/stable - name: Run integration tests diff --git a/requirements.txt b/requirements.txt index d8e90a0..2db670a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,4 @@ requests == 2.31.0 jsonschema==4.21.1 cryptography >= 3.4.8 lightkube===0.15.0 -lightkube-models==1.29.0.6 pydantic<2.0 diff --git a/tests/integration/test_charm.py b/tests/integration/test_charm.py index b5b25c4..38ced1e 100644 --- a/tests/integration/test_charm.py +++ b/tests/integration/test_charm.py @@ -40,7 +40,7 @@ async def test_build_and_deploy(ops_test: OpsTest, charm: str, test_charm: str) charm, resources=resources, application_name=OPENFGA_APP, series="jammy", trust=True ), ops_test.model.deploy( - "postgresql-k8s", application_name="postgresql", channel="edge", trust=True + "postgresql-k8s", application_name="postgresql", channel="14/stable", trust=True ), ops_test.model.deploy( test_charm,