|
1 | 1 | from github import Auth |
2 | 2 | from github import Github |
3 | 3 | from keyvaluestore import KeyValueStore |
| 4 | +from models import Image, Repository, ImagesData |
4 | 5 |
|
5 | 6 | import datetime |
6 | | -import json |
7 | 7 | import os |
8 | 8 | import threading |
9 | 9 | import time |
@@ -41,23 +41,22 @@ def get_state(): |
41 | 41 | if "Internal" in categories: |
42 | 42 | continue |
43 | 43 | version = "latest" if "development_versions_items" not in readme_vars else readme_vars["development_versions_items"][0]["tag"] |
44 | | - images.append({ |
45 | | - "name": repo.full_name.replace("linuxserver/docker-", ""), |
46 | | - "version": version, |
47 | | - "category": categories, |
48 | | - "stable": version == "latest", |
49 | | - "deprecated": False |
50 | | - }) |
51 | | - return {"status": "OK", "data": {"repositories": {"linuxserver": images}}} |
| 44 | + images.append(Image( |
| 45 | + name=repo.full_name.replace("linuxserver/docker-", ""), |
| 46 | + version=version, |
| 47 | + category=categories, |
| 48 | + stable=version == "latest", |
| 49 | + deprecated=False |
| 50 | + )) |
| 51 | + return ImagesData(repositories=Repository(linuxserver=images)).model_dump_json() |
52 | 52 |
|
53 | 53 | def update_images(): |
54 | 54 | with KeyValueStore(invalidate_hours=INVALIDATE_HOURS, readonly=False) as kv: |
55 | 55 | if "images" in kv or CI == "1": |
56 | 56 | print(f"{datetime.datetime.now()} - skipped - already updated") |
57 | 57 | return |
58 | 58 | print(f"{datetime.datetime.now()} - updating images") |
59 | | - current_state = get_state() |
60 | | - kv["images"] = json.dumps(current_state) |
| 59 | + kv["images"] = get_state() |
61 | 60 | print(f"{datetime.datetime.now()} - updated images") |
62 | 61 |
|
63 | 62 | class UpdateImages(threading.Thread): |
|
0 commit comments