Handle more timestamps

This commit is contained in:
Stéphane Bidoul 2021-10-28 18:51:55 +02:00
parent d2e23443e1
commit 9982c80b41
No known key found for this signature in database
GPG key ID: BCAB2555446B5B92
3 changed files with 8 additions and 7 deletions

View file

@ -1,3 +1,4 @@
import datetime
from typing import List, Optional
from fastapi import APIRouter, Depends, HTTPException, status
@ -35,7 +36,6 @@ class Repo(BaseModel):
class Build(BaseModel):
# TODO created: datetime.datetime
name: str
repo: str
target_branch: str
@ -44,6 +44,8 @@ class Build(BaseModel):
image: str
link: str
status: models.BuildStatus
created: datetime.datetime
last_scaled: Optional[datetime.datetime]
class Config:
orm_mode = True
@ -51,7 +53,6 @@ class Build(BaseModel):
class BranchOrPull(BaseModel):
# created: datetime.datetime
repo: str
target_branch: str
pr: Optional[int]

View file

@ -84,7 +84,7 @@ class BuildsDb:
build.status,
build.todo,
build.last_scaled,
build.created,
build.created.isoformat(),
),
)

View file

@ -1,6 +1,6 @@
import datetime
import logging
import uuid
from datetime import datetime
from enum import Enum
from typing import Optional
@ -36,7 +36,7 @@ class Build(BaseModel):
status: BuildStatus
todo: Optional[BuildTodo]
last_scaled: Optional[str]
created: str
created: datetime.datetime
@classmethod
def from_deployment(cls, deployment: V1Deployment) -> "Build":
@ -52,7 +52,7 @@ class Build(BaseModel):
todo=deployment.metadata.annotations["runboat/todo"] or None,
last_scaled=deployment.metadata.annotations.get("runboat/last-scaled")
or None,
created="TODO", # deployment.metadata.creationTimestamp,
created=deployment.metadata.creation_timestamp,
)
@classmethod
@ -124,7 +124,7 @@ class Build(BaseModel):
# record last scaled time for the stopper and undeployer
"op": "replace",
"path": "/metadata/annotations/runboat~1last-scaled",
"value": datetime.utcnow().isoformat() + "Z",
"value": datetime.datetime.utcnow().isoformat() + "Z",
},
{
# set replicas