Skip to content

Commit 6bf4fde

Browse files
committed
fix image update whitelist script to paginate through all images
1 parent 289d01f commit 6bf4fde

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

update_image_whitelist.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,24 @@
77
headers = {'Authorization': f'Bearer {github_token}'}
88

99
if use_ghcr:
10-
response = requests.get(
11-
"https://api.github.com/orgs/Ellipsis-Labs/packages/container/solana/versions?per_page=100",
12-
headers=headers
13-
)
14-
if response.status_code != 200:
15-
raise Exception(f"Failed to get Docker images: {response.status_code} {response.text}")
16-
results = response.json()
10+
url = "https://api.github.com/orgs/Ellipsis-Labs/packages/container/solana/versions?per_page=100"
11+
results = []
12+
while url:
13+
response = requests.get(url, headers=headers)
14+
if response.status_code != 200:
15+
raise Exception(f"Failed to get Docker images: {response.status_code} {response.text}")
16+
results.extend(response.json())
17+
18+
# Check for pagination
19+
url = None
20+
if 'Link' in response.headers:
21+
links = response.headers['Link']
22+
for link in links.split(','):
23+
if 'rel="next"' in link:
24+
url = link[link.find('<') + 1:link.find('>')]
25+
break
26+
if response.status_code != 200:
27+
raise Exception(f"Failed to get Docker images: {response.status_code} {response.text}")
1728
else:
1829
response = requests.get(
1930
"https://hub.docker.com/v2/namespaces/ellipsislabs/repositories/solana/tags?page_size=1000"

0 commit comments

Comments
 (0)