aboutsummaryrefslogtreecommitdiffstats
path: root/arthur/apis/kubernetes
diff options
context:
space:
mode:
Diffstat (limited to 'arthur/apis/kubernetes')
-rw-r--r--arthur/apis/kubernetes/deployments.py6
-rw-r--r--arthur/apis/kubernetes/jobs.py7
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: