Skip to content

Commit

Permalink
Replace GrafanaDashboard with LZMABase64
Browse files Browse the repository at this point in the history
  • Loading branch information
sed-i committed Dec 17, 2024
1 parent e6a53ab commit 31ca46b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from charms.loki_k8s.v1.loki_push_api import LokiPushApiProvider
from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointConsumer
from charms.tempo_coordinator_k8s.v0.charm_tracing import trace_charm
from cosl import GrafanaDashboard
from cosl import LZMABase64
from ops.main import main
from ops.pebble import Layer

Expand All @@ -32,7 +32,7 @@
GrafanaAgentCharm,
LokiPushApiProvider,
MetricsEndpointConsumer,
GrafanaDashboard,
LZMABase64,
),
)
class GrafanaAgentK8sCharm(GrafanaAgentCharm):
Expand Down Expand Up @@ -156,9 +156,9 @@ def dashboards(self) -> list:
if "templates" not in dashboards:
continue
for template in dashboards["templates"]:
content = GrafanaDashboard(
content = json.loads(LZMABase64.decompress(
dashboards["templates"][template].get("content")
)._deserialize()
))
entry = {
"charm": dashboards["templates"][template].get("charm", "charm_name"),
"relation_id": rel.id,
Expand Down
4 changes: 2 additions & 2 deletions tests/scenario/test_dashboard_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# See LICENSE file for licensing details.
import json

from cosl import GrafanaDashboard
from cosl import LZMABase64
from ops.testing import Container, Relation, State


def encode_as_dashboard(dct: dict):
return GrafanaDashboard._serialize(json.dumps(dct).encode("utf-8"))
return LZMABase64.compress(json.dumps(dct))


def test_dashboard_propagation(ctx):
Expand Down

0 comments on commit 31ca46b

Please sign in to comment.