mirror of
https://forgejo.altau.su/lego/lego-monitoring.git
synced 2026-03-12 05:35:19 +00:00
use NestedDeserializableDataclass for config
This commit is contained in:
parent
96664684f8
commit
3eb358d618
13 changed files with 188 additions and 130 deletions
|
|
@ -11,6 +11,7 @@ from urllib.parse import urlparse
|
|||
import uplink
|
||||
|
||||
from alerting import alerts
|
||||
from alerting.enum import AlertType, Severity
|
||||
from misc import cvars
|
||||
|
||||
|
||||
|
|
@ -67,12 +68,12 @@ class DockerRegistryClient(uplink.Consumer):
|
|||
|
||||
|
||||
async def get_updated_images() -> list[str]:
|
||||
check_config = cvars.config.get()["checks"]["docker_registry"]
|
||||
hub_client = DockerHubClient(base_url=check_config["hub_url"], client=uplink.AiohttpClient())
|
||||
check_config = cvars.config.get().checks.docker_registry
|
||||
hub_client = DockerHubClient(base_url=check_config.hub_url, client=uplink.AiohttpClient())
|
||||
now = datetime.datetime.now(datetime.timezone.utc)
|
||||
|
||||
updated_images = []
|
||||
for image in check_config["images"]:
|
||||
for image in check_config.images:
|
||||
image_split = image.split("/")
|
||||
match len(image_split):
|
||||
case 2:
|
||||
|
|
@ -84,9 +85,9 @@ async def get_updated_images() -> list[str]:
|
|||
except Exception as exc:
|
||||
await alerts.send_alert(
|
||||
alerts.Alert(
|
||||
alert_type=alerts.AlertType.ERROR,
|
||||
alert_type=AlertType.ERROR,
|
||||
message=f"Could not query Docker Hub: {repr(exc)}, see logs",
|
||||
severity=alerts.Severity.CRITICAL,
|
||||
severity=Severity.CRITICAL,
|
||||
)
|
||||
)
|
||||
logging.error(traceback.format_exc())
|
||||
|
|
@ -111,9 +112,9 @@ async def get_updated_images() -> list[str]:
|
|||
except Exception as exc:
|
||||
await alerts.send_alert(
|
||||
alerts.Alert(
|
||||
alert_type=alerts.AlertType.ERROR,
|
||||
alert_type=AlertType.ERROR,
|
||||
message=f"Could not query Docker registry {registry}: {repr(exc)}, see logs",
|
||||
severity=alerts.Severity.CRITICAL,
|
||||
severity=Severity.CRITICAL,
|
||||
)
|
||||
)
|
||||
logging.error(traceback.format_exc())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue