Skip to content

Commit

Permalink
Merge pull request #87 from ngundotra/update-whitelist
Browse files Browse the repository at this point in the history
Fix image update whitelist script to paginate through all images
  • Loading branch information
ngundotra authored Oct 24, 2024
2 parents 4a7665e + 6bf4fde commit 214ba84
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions update_image_whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,24 @@
headers = {'Authorization': f'Bearer {github_token}'}

if use_ghcr:
response = requests.get(
"https://api.github.com/orgs/Ellipsis-Labs/packages/container/solana/versions?per_page=100",
headers=headers
)
if response.status_code != 200:
raise Exception(f"Failed to get Docker images: {response.status_code} {response.text}")
results = response.json()
url = "https://api.github.com/orgs/Ellipsis-Labs/packages/container/solana/versions?per_page=100"
results = []
while url:
response = requests.get(url, headers=headers)
if response.status_code != 200:
raise Exception(f"Failed to get Docker images: {response.status_code} {response.text}")
results.extend(response.json())

# Check for pagination
url = None
if 'Link' in response.headers:
links = response.headers['Link']
for link in links.split(','):
if 'rel="next"' in link:
url = link[link.find('<') + 1:link.find('>')]
break
if response.status_code != 200:
raise Exception(f"Failed to get Docker images: {response.status_code} {response.text}")
else:
response = requests.get(
"https://hub.docker.com/v2/namespaces/ellipsislabs/repositories/solana/tags?page_size=1000"
Expand Down

0 comments on commit 214ba84

Please sign in to comment.