Skip to content

Commit 37374a3

Browse files
chore: update charm libraries
1 parent 006d3cf commit 37374a3

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

lib/charms/grafana_k8s/v0/grafana_dashboard.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def __init__(self, *args):
217217
# Increment this PATCH version before using `charmcraft publish-lib` or reset
218218
# to 0 if you are raising the major API version
219219

220-
LIBPATCH = 47
220+
LIBPATCH = 48
221221

222222
PYDEPS = ["cosl >= 0.0.50"]
223223

@@ -585,9 +585,19 @@ def _convert_dashboard_fields(cls, content: str, inject_dropdowns: bool = True)
585585
datasources[template_value["name"]] = template_value["query"].lower()
586586

587587
# Put our own variables in the template
588+
# We only want to inject our own dropdowns IFF they are NOT
589+
# already in the template coming over relation data.
590+
# We'll store all dropdowns in the template from the provider
591+
# in a set. We'll add our own if they are not in this set.
592+
existing_names = {
593+
item.get("name")
594+
for item in dict_content["templating"]["list"]
595+
}
596+
588597
for d in template_dropdowns: # type: ignore
589-
if d not in dict_content["templating"]["list"]:
598+
if d.get("name") not in existing_names:
590599
dict_content["templating"]["list"].insert(0, d)
600+
existing_names.add(d.get("name"))
591601

592602
dict_content = cls._replace_template_fields(dict_content, datasources, existing_templates)
593603
return json.dumps(dict_content)

0 commit comments

Comments
 (0)