Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

directly vendor schema files #110

Merged
merged 18 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 21 additions & 5 deletions src/cosl/interfaces/datasource_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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."""

Expand Down
2 changes: 1 addition & 1 deletion tests/test_datasource_exchange.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,6 +9,7 @@
DatasourceExchange,
DSExchangeAppData,
EndpointValidationError,
GrafanaDatasource,
)


Expand Down
Loading