diff --git a/pyproject.toml b/pyproject.toml index 79e6a91..f9c4d55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,10 +17,10 @@ dependencies = [ "pydantic", "tenacity", "jsonschema", + "cryptography", "PyYAML", "typing-extensions", "lightkube>=v0.15.4", - "charm-relation-interfaces @ git+https://github.com/canonical/charm-relation-interfaces", ] classifiers = [ "Programming Language :: Python :: 3.8", diff --git a/src/cosl/interfaces/datasource_exchange.py b/src/cosl/interfaces/datasource_exchange.py index 9105e44..cd173e1 100644 --- a/src/cosl/interfaces/datasource_exchange.py +++ b/src/cosl/interfaces/datasource_exchange.py @@ -8,7 +8,6 @@ for the interface specification. """ - # FIXME: the interfaces import (because it's a git dep perhaps?) # can't be type-checked, which breaks everything # pyright: reportMissingImports=false @@ -30,11 +29,8 @@ ) import ops -from interfaces.grafana_datasource_exchange.v0.schema import ( - GrafanaDatasource, - GrafanaSourceAppData, -) from ops import CharmBase +from pydantic import BaseModel, Field, Json from typing_extensions import TypedDict import cosl.interfaces.utils @@ -45,6 +41,26 @@ DS_EXCHANGE_INTERFACE_NAME = "grafana_datasource_exchange" +# FIXME copy-pasta'd from charm-relation-interfaces. Keep in sync! +# see https://github.com/canonical/charm-relation-interfaces/issues/213 +class GrafanaDatasource(BaseModel): + """GrafanaDatasource model.""" + + type: str = Field( + description="Type of the datasource, typically one of " + "https://grafana.com/docs/grafana/latest/datasources/#built-in-core-data-sources.", + examples=["tempo", "loki", "prometheus", "elasticsearch"], + ) + uid: str = Field(description="Grafana datasource UID, as assigned by Grafana.") + grafana_uid: str = Field(description="Grafana UID.") + + +class GrafanaSourceAppData(BaseModel): + """Application databag model for both sides of this interface.""" + + datasources: Json[List[GrafanaDatasource]] + + class DSExchangeAppData(cosl.interfaces.utils.DatabagModelV2, GrafanaSourceAppData): """App databag schema for both sides of this interface.""" diff --git a/tests/test_datasource_exchange.py b/tests/test_datasource_exchange.py index 9b6b57a..76250ef 100644 --- a/tests/test_datasource_exchange.py +++ b/tests/test_datasource_exchange.py @@ -1,7 +1,6 @@ import json import pytest -from interfaces.grafana_datasource_exchange.v0.schema import GrafanaDatasource from ops import CharmBase, Framework from scenario import Context, Relation, State from scenario.errors import UncaughtCharmError @@ -10,6 +9,7 @@ DatasourceExchange, DSExchangeAppData, EndpointValidationError, + GrafanaDatasource, )