Skip to content
This repository was archived by the owner on Jul 8, 2026. It is now read-only.
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
8 changes: 4 additions & 4 deletions lib/charms/grafana_agent/v0/cos_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class _MetricsEndpointDict(TypedDict):

LIBID = "dc15fa84cef84ce58155fb84f6c6213a"
LIBAPI = 0
LIBPATCH = 20
LIBPATCH = 21

PYDEPS = ["cosl >= 0.0.50", "pydantic"]

Expand Down Expand Up @@ -472,7 +472,7 @@ def dump(self, databag: Optional[MutableMapping] = None, clear: bool = True):
return databag


class CosAgentProviderUnitData(DatabagModel):
class CosAgentProviderUnitData(DatabagModel): # type: ignore
"""Unit databag model for `cos-agent` relation."""

# The following entries are the same for all units of the same principal.
Expand All @@ -499,7 +499,7 @@ class CosAgentProviderUnitData(DatabagModel):
KEY: ClassVar[str] = "config"


class CosAgentPeersUnitData(DatabagModel):
class CosAgentPeersUnitData(DatabagModel): # type: ignore
"""Unit databag model for `peers` cos-agent machine charm peer relation."""

# We need the principal unit name and relation metadata to be able to render identifiers
Expand Down Expand Up @@ -598,7 +598,7 @@ class Receiver(pydantic.BaseModel):
)


class CosAgentRequirerUnitData(DatabagModel): # noqa: D101
class CosAgentRequirerUnitData(DatabagModel): # type: ignore
"""Application databag model for the COS-agent requirer."""

receivers: List[Receiver] = pydantic.Field(
Expand Down
14 changes: 13 additions & 1 deletion lib/charms/operator_libs_linux/v2/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@

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

PYDEPS = ["opentelemetry-api"]

Expand Down Expand Up @@ -149,6 +149,7 @@ class _SnapDict(TypedDict, total=True):
name: str
channel: str
revision: str
version: str
confinement: str
apps: NotRequired[list[dict[str, JSONType]] | None]

Expand Down Expand Up @@ -309,6 +310,7 @@ class Snap:
- channel: "stable", "candidate", "beta", and "edge" are common
- revision: a string representing the snap's revision
- confinement: "classic", "strict", or "devmode"
- version: a string representing the snap's version, if set by the snap author
"""

def __init__(
Expand All @@ -320,6 +322,8 @@ def __init__(
confinement: str,
apps: list[dict[str, JSONType]] | None = None,
cohort: str | None = None,
*,
version: str | None = None,
) -> None:
self._name = name
self._state = state
Expand All @@ -328,6 +332,7 @@ def __init__(
self._confinement = confinement
self._cohort = cohort or ""
self._apps = apps or []
self._version = version
self._snap_client = SnapClient()

def __eq__(self, other: object) -> bool:
Expand Down Expand Up @@ -783,6 +788,11 @@ def held(self) -> bool:
info = self._snap("info")
return "hold:" in info

@property
def version(self) -> str | None:
"""Returns the version for a snap."""
return self._version


class _UnixSocketConnection(http.client.HTTPConnection):
"""Implementation of HTTPConnection that connects to a named Unix socket."""
Expand Down Expand Up @@ -1048,6 +1058,7 @@ def _load_installed_snaps(self) -> None:
revision=i["revision"],
confinement=i["confinement"],
apps=i.get("apps"),
version=i.get("version"),
)
self._snap_map[snap.name] = snap

Expand All @@ -1067,6 +1078,7 @@ def _load_info(self, name: str) -> Snap:
revision=info["revision"],
confinement=info["confinement"],
apps=None,
version=info.get("version"),
)


Expand Down
Loading