Browse Source

download: compute new versions from Github API

We obtain the set of version from Github, then for each component we do
a set comparison to determine which versions we don't have.
pull/11891/head
Max Gautier 9 months ago
parent
commit
9f58ba60f3
Failed to extract signature
1 changed files with 33 additions and 2 deletions
  1. 35
      scripts/download_hash.py

35
scripts/download_hash.py

@ -5,6 +5,7 @@
# with new hashes. # with new hashes.
import sys import sys
import os
from itertools import count, groupby from itertools import count, groupby
from collections import defaultdict from collections import defaultdict
@ -95,8 +96,8 @@ downloads = {
# crun : PGP signatures # crun : PGP signatures
# cri_dockerd: no checksums or signatures # cri_dockerd: no checksums or signatures
# helm_archive: PGP signatures # helm_archive: PGP signatures
# krew_archive: different yaml structure
# calico_crds_archive: different yaml structure
# krew_archive: different yaml structure (in our download)
# calico_crds_archive: different yaml structure (in our download)
# TODO: # TODO:
# noarch support -> k8s manifests, helm charts # noarch support -> k8s manifests, helm charts
@ -157,6 +158,36 @@ def download_hash(only_downloads: [str]) -> None:
hash_file.raise_for_status() hash_file.raise_for_status()
return download_hash_extract[download](hash_file.content.decode()) return download_hash_extract[download](hash_file.content.decode())
nodes_ids = [x['graphql_id'] for x in downloads.values()]
ql_params = {
'repoWithReleases': nodes_ids,
'repoWithTags': [],
}
with open("list_releases.graphql") as query:
response = s.post("https://api.github.com/graphql",
json={'query': query.read(), 'variables': ql_params},
headers={
"Authorization": f"Bearer {os.environ['API_KEY']}",
}
)
response.raise_for_status()
github_versions = dict(zip([k + '_checksums' for k in downloads.keys()],
[
{r["tagName"] for r in repo["releases"]["nodes"]
if not r["isPrerelease"] # and r["releaseAssets"]["totalCount"] > 2
# instead here we need optionnal custom predicate per-component to filter out
}
for repo in response.json()["data"]["with_releases"]
],
strict=True))
new_versions = {
component: github_versions[component] - set(list(archs.values())[0].keys())
for component, archs in data.items() if component in [k + '_checksums' for k in downloads.keys()]
}
for download, url in (downloads if only_downloads == [] for download, url in (downloads if only_downloads == []
else {k:downloads[k] for k in downloads.keys() & only_downloads}).items(): else {k:downloads[k] for k in downloads.keys() & only_downloads}).items():
checksum_name = f"{download}_checksums" checksum_name = f"{download}_checksums"

Loading…
Cancel
Save