Handle more timestamps
This commit is contained in:
parent
d2e23443e1
commit
9982c80b41
3 changed files with 8 additions and 7 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import datetime
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
|
|
@ -35,7 +36,6 @@ class Repo(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
class Build(BaseModel):
|
class Build(BaseModel):
|
||||||
# TODO created: datetime.datetime
|
|
||||||
name: str
|
name: str
|
||||||
repo: str
|
repo: str
|
||||||
target_branch: str
|
target_branch: str
|
||||||
|
|
@ -44,6 +44,8 @@ class Build(BaseModel):
|
||||||
image: str
|
image: str
|
||||||
link: str
|
link: str
|
||||||
status: models.BuildStatus
|
status: models.BuildStatus
|
||||||
|
created: datetime.datetime
|
||||||
|
last_scaled: Optional[datetime.datetime]
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
|
|
@ -51,7 +53,6 @@ class Build(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
class BranchOrPull(BaseModel):
|
class BranchOrPull(BaseModel):
|
||||||
# created: datetime.datetime
|
|
||||||
repo: str
|
repo: str
|
||||||
target_branch: str
|
target_branch: str
|
||||||
pr: Optional[int]
|
pr: Optional[int]
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ class BuildsDb:
|
||||||
build.status,
|
build.status,
|
||||||
build.todo,
|
build.todo,
|
||||||
build.last_scaled,
|
build.last_scaled,
|
||||||
build.created,
|
build.created.isoformat(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ class Build(BaseModel):
|
||||||
status: BuildStatus
|
status: BuildStatus
|
||||||
todo: Optional[BuildTodo]
|
todo: Optional[BuildTodo]
|
||||||
last_scaled: Optional[str]
|
last_scaled: Optional[str]
|
||||||
created: str
|
created: datetime.datetime
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_deployment(cls, deployment: V1Deployment) -> "Build":
|
def from_deployment(cls, deployment: V1Deployment) -> "Build":
|
||||||
|
|
@ -52,7 +52,7 @@ class Build(BaseModel):
|
||||||
todo=deployment.metadata.annotations["runboat/todo"] or None,
|
todo=deployment.metadata.annotations["runboat/todo"] or None,
|
||||||
last_scaled=deployment.metadata.annotations.get("runboat/last-scaled")
|
last_scaled=deployment.metadata.annotations.get("runboat/last-scaled")
|
||||||
or None,
|
or None,
|
||||||
created="TODO", # deployment.metadata.creationTimestamp,
|
created=deployment.metadata.creation_timestamp,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -124,7 +124,7 @@ class Build(BaseModel):
|
||||||
# record last scaled time for the stopper and undeployer
|
# record last scaled time for the stopper and undeployer
|
||||||
"op": "replace",
|
"op": "replace",
|
||||||
"path": "/metadata/annotations/runboat~1last-scaled",
|
"path": "/metadata/annotations/runboat~1last-scaled",
|
||||||
"value": datetime.utcnow().isoformat() + "Z",
|
"value": datetime.datetime.utcnow().isoformat() + "Z",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
# set replicas
|
# set replicas
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue