Skip to content

Commit

Permalink
chore: add sunset date to cluster list
Browse files Browse the repository at this point in the history
Merge pull request #91 from Getdeck/feat/cluster-list-sunset

* chore: add sunset date to cluster list
  • Loading branch information
tschale authored Jul 4, 2023
2 parents 07dbb1d + e662018 commit 699d98a
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 16 deletions.
1 change: 1 addition & 0 deletions app/beiboot_api/cluster/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ class ClusterStateResponse(BaseModel):
id: str
name: str | None
state: BeibootState | None
sunset: datetime | None


class ClusterInfoResponse(BaseModel):
Expand Down
8 changes: 7 additions & 1 deletion app/beiboot_api/routers/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ async def cluster_list(

response = []
for beiboot in beiboots:
response.append(ClusterStateResponse(id=beiboot.name, name=beiboot.labels.get("name"), state=beiboot.state))
if beiboot.sunset:
sunset = datetime.strptime(beiboot.sunset, "%Y-%m-%dT%H:%M:%S.%fZ")
else:
sunset = None
response.append(
ClusterStateResponse(id=beiboot.name, name=beiboot.labels.get("name"), state=beiboot.state, sunset=sunset)
)

return paginate(response, params)

Expand Down
Loading

0 comments on commit 699d98a

Please sign in to comment.