diff options
| author | 2023-04-27 22:28:08 +0100 | |
|---|---|---|
| committer | 2023-04-27 22:28:08 +0100 | |
| commit | fffe818885154fcc54b399f13155ee95a1a408bc (patch) | |
| tree | 86ead71bb3b5d57f886b77a45455d43bfa2cd5ec /arthur/apis/kubernetes | |
| parent | build(deps): bump pydantic from 1.10.5 to 1.10.7 (#50) (diff) | |
| parent | Fix linting errors from new ruff rules (diff) | |
Merge pull request #54 from python-discord/migrate-to-ruff
Migrate to ruff
Diffstat (limited to 'arthur/apis/kubernetes')
| -rw-r--r-- | arthur/apis/kubernetes/deployments.py | 6 | ||||
| -rw-r--r-- | arthur/apis/kubernetes/jobs.py | 7 |
2 files changed, 5 insertions, 8 deletions
diff --git a/arthur/apis/kubernetes/deployments.py b/arthur/apis/kubernetes/deployments.py index f7b4d5c..971c4a0 100644 --- a/arthur/apis/kubernetes/deployments.py +++ b/arthur/apis/kubernetes/deployments.py @@ -1,5 +1,5 @@ """APIs for working with Kubernetes deployments.""" -from datetime import datetime, timezone +from datetime import UTC, datetime from kubernetes_asyncio import client from kubernetes_asyncio.client.api_client import ApiClient @@ -18,9 +18,7 @@ async def restart_deployment(deployment: str, namespace: str) -> None: "template": { "metadata": { "annotations": { - "king-arthur.pydis.com/restartedAt": datetime.now( - timezone.utc - ).isoformat() + "king-arthur.pydis.com/restartedAt": datetime.now(UTC).isoformat() } } } diff --git a/arthur/apis/kubernetes/jobs.py b/arthur/apis/kubernetes/jobs.py index a5edc53..606177c 100644 --- a/arthur/apis/kubernetes/jobs.py +++ b/arthur/apis/kubernetes/jobs.py @@ -1,19 +1,18 @@ """APIs for interacting with Kubernetes Jobs & Cronjobs.""" -from typing import Any, Optional +from typing import Any from kubernetes_asyncio import client from kubernetes_asyncio.client.api_client import ApiClient from kubernetes_asyncio.client.models import V1CronJob, V1CronJobList, V1Job -async def list_cronjobs(namespace: Optional[str] = None) -> V1CronJobList: +async def list_cronjobs(namespace: str | None = None) -> V1CronJobList: """Query the Kubernetes API for a list of cronjobss in the provided namespace.""" async with ApiClient() as api: api = client.BatchV1Api(api) if namespace: return await api.list_namespaced_cron_job(namespace) - else: - return await api.list_cron_job_for_all_namespaces() + return await api.list_cron_job_for_all_namespaces() async def get_cronjob(namespace: str, cronjob_name: str) -> V1CronJob: |