Skip to content

Commit

Permalink
Update charm libraries (#10)
Browse files Browse the repository at this point in the history
* chore: update charm libraries

* update trivyignore

---------

Co-authored-by: Arturo Seijas <[email protected]>
  • Loading branch information
is-devops-bot and arturo-seijas authored Aug 20, 2024
1 parent a6b80da commit 0adce49
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ CVE-2022-1471
CVE-2024-21634
# nodejs
CVE-2024-37890
# clojure
CVE-2024-22871
20 changes: 17 additions & 3 deletions lib/charms/smtp_integrator/v0/smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ 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 = 9
LIBPATCH = 11

PYDEPS = ["pydantic>=2"]

# pylint: disable=wrong-import-position
import itertools
import logging
import typing
from ast import literal_eval
from enum import Enum
from typing import Dict, Optional

Expand Down Expand Up @@ -127,7 +128,8 @@ class SmtpRelationData(BaseModel):
password_id: The secret ID where the SMTP AUTH password for the SMTP relay is stored.
auth_type: The type used to authenticate with the SMTP relay.
transport_security: The security protocol to use for the outgoing SMTP relay.
domain: The domain used by the sent emails from SMTP relay.
domain: The domain used by the emails sent from SMTP relay.
skip_ssl_verify: Specifies if certificate trust verification is skipped in the SMTP relay.
"""

host: str = Field(..., min_length=1)
Expand All @@ -138,6 +140,7 @@ class SmtpRelationData(BaseModel):
auth_type: AuthType
transport_security: TransportSecurity
domain: Optional[str] = None
skip_ssl_verify: Optional[bool] = False

def to_relation_data(self) -> Dict[str, str]:
"""Convert an instance of SmtpRelationData to the relation representation.
Expand All @@ -150,6 +153,7 @@ def to_relation_data(self) -> Dict[str, str]:
"port": str(self.port),
"auth_type": self.auth_type.value,
"transport_security": self.transport_security.value,
"skip_ssl_verify": str(self.skip_ssl_verify),
}
if self.domain:
result["domain"] = self.domain
Expand All @@ -173,7 +177,8 @@ class SmtpDataAvailableEvent(ops.RelationEvent):
password_id: The secret ID where the SMTP AUTH password for the SMTP relay is stored.
auth_type: The type used to authenticate with the SMTP relay.
transport_security: The security protocol to use for the outgoing SMTP relay.
domain: The domain used by the sent emails from SMTP relay.
domain: The domain used by the emails sent from SMTP relay.
skip_ssl_verify: Specifies if certificate trust verification is skipped in the SMTP relay.
"""

@property
Expand Down Expand Up @@ -224,6 +229,14 @@ def domain(self) -> str:
assert self.relation.app
return typing.cast(str, self.relation.data[self.relation.app].get("domain"))

@property
def skip_ssl_verify(self) -> bool:
"""Fetch the skip_ssl_verify flag from the relation."""
assert self.relation.app
return literal_eval(
typing.cast(str, self.relation.data[self.relation.app].get("skip_ssl_verify"))
)


class SmtpRequiresEvents(ops.CharmEvents):
"""SMTP events.
Expand Down Expand Up @@ -287,6 +300,7 @@ def _get_relation_data_from_relation(self, relation: ops.Relation) -> SmtpRelati
auth_type=AuthType(relation_data.get("auth_type")),
transport_security=TransportSecurity(relation_data.get("transport_security")),
domain=relation_data.get("domain"),
skip_ssl_verify=typing.cast(bool, relation_data.get("skip_ssl_verify")),
)

def _is_relation_data_valid(self, relation: ops.Relation) -> bool:
Expand Down

0 comments on commit 0adce49

Please sign in to comment.