- Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathdocker_hub.py
More file actions
Latest commit
57 lines (48 loc) · 1.26 KB
/
Copy pathdocker_hub.py
File metadata and controls
57 lines (48 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
fromtypingimportTypedDict
importrequests
classDockerImageDict(TypedDict):
architecture: str
features: str
variant: str|None
digest: str
os: str
os_features: str
os_version: str|None
size: int
status: str
last_pulled: str
last_pushed: str
classDockerTagDict(TypedDict):
creator: int
id: int
images: list[DockerImageDict]
last_updated: str
last_updater: int
last_updater_username: str
name: str
repository: int
full_size: int
v2: bool
tag_status: str
tag_last_pulled: str
tag_last_pushed: str
media_type: str
content_type: str
digest: str
classDockerTagResponse(TypedDict):
count: int
next: str|None
previous: str|None
results: list[DockerTagDict]
deffetch_tags(package: str, page: int=1) ->list[DockerTagDict]:
"""Fetch available docker tags."""
result=requests.get(
f"https://registry.hub.docker.com/v2/namespaces/library/repositories/{package}/tags",
params={"page": page, "page_size": 100},
timeout=10.0,
)
result.raise_for_status()
data: DockerTagResponse=result.json()
ifnotdata["next"]:
returndata["results"]
returndata["results"] +fetch_tags(package, page=page+1)