Skip to content

Commit

Permalink
chore: update charm libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
amandahla committed Feb 9, 2025
1 parent 2e6f091 commit 044b6af
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
12 changes: 7 additions & 5 deletions lib/charms/grafana_k8s/v0/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def __init__(self, *args):
# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version

LIBPATCH = 39
LIBPATCH = 41

PYDEPS = ["cosl >= 0.0.50"]

Expand Down Expand Up @@ -417,8 +417,7 @@ def __init__(
self.expected_relation_interface = expected_relation_interface
self.actual_relation_interface = actual_relation_interface
self.message = (
"The '{}' relation has '{}' as "
"interface rather than the expected '{}'".format(
"The '{}' relation has '{}' as " "interface rather than the expected '{}'".format(
relation_name, actual_relation_interface, expected_relation_interface
)
)
Expand Down Expand Up @@ -634,7 +633,10 @@ def _replace_template_fields( # noqa: C901
deletions = []
for tmpl in dict_content["templating"]["list"]:
if tmpl["name"] and tmpl["name"] in used_replacements:
deletions.append(tmpl)
# it might happen that existing template var name is the same as the one we insert (i.e prometheusds or lokids)
# in that case, we want to pop the existing one only.
if tmpl not in DATASOURCE_TEMPLATE_DROPDOWNS:
deletions.append(tmpl)

for d in deletions:
dict_content["templating"]["list"].remove(d)
Expand Down Expand Up @@ -1601,7 +1603,7 @@ def _render_dashboards_and_signal_changed(self, relation: Relation) -> bool: #

if not coerced_data == stored_data:
stored_dashboards = self.get_peer_data("dashboards")
stored_dashboards[relation.id] = stored_data
stored_dashboards[str(relation.id)] = stored_data
self.set_peer_data("dashboards", stored_dashboards)
return True
return None # type: ignore
Expand Down
26 changes: 24 additions & 2 deletions lib/charms/smtp_integrator/v0/smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _on_config_changed(self, _) -> None:

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 14
LIBPATCH = 15

PYDEPS = ["pydantic>=2"]

Expand All @@ -89,6 +89,14 @@ def _on_config_changed(self, _) -> None:
LEGACY_RELATION_NAME = "smtp-legacy"


class SmtpError(Exception):
"""Common ancestor for Smtp related exceptions."""


class SecretError(SmtpError):
"""Common ancestor for Secrets related exceptions."""


class TransportSecurity(str, Enum):
"""Represent the transport security values.
Expand Down Expand Up @@ -295,11 +303,25 @@ def _get_relation_data_from_relation(
relation_data = relation.data[relation.app]
if not relation_data:
return None

password = relation_data.get("password")
if password is None and relation_data.get("password_id"):
try:
password = (
self.model.get_secret(id=relation_data.get("password_id"))
.get_content()
.get("password")
)
except ops.model.ModelError as exc:
raise SecretError(
f"Could not consume secret {relation_data.get('password_id')}"
) from exc

return SmtpRelationData(
host=typing.cast(str, relation_data.get("host")),
port=typing.cast(int, relation_data.get("port")),
user=relation_data.get("user"),
password=relation_data.get("password"),
password=password,
password_id=relation_data.get("password_id"),
auth_type=AuthType(relation_data.get("auth_type")),
transport_security=TransportSecurity(relation_data.get("transport_security")),
Expand Down

0 comments on commit 044b6af

Please sign in to comment.