Browse Source

Filter by github results InvalidVersion

Containerd use the same repository for releases of it's gRPC API (which
we are not interested in).
Conveniently, those releases have tags which are not valid version
number (being prefixed with 'api/').

This could also be potentially useful for similar cases.
The risk of missing releases because of this are low, since it would
require that a project issue a new release with an invalid format, then
switch back to the previous format (or we miss the fact it's not
updating for a long period of time).
pull/11891/head
Max Gautier 2 months ago
parent
commit
ae68766015
Failed to extract signature
1 changed files with 13 additions and 4 deletions
  1. 17
      scripts/download_hash.py

17
scripts/download_hash.py

@ -13,7 +13,9 @@ from functools import cache
import argparse
import requests
from ruamel.yaml import YAML
from packaging.version import Version
from packaging.version import Version, InvalidVersion
from typing import Optional
CHECKSUMS_YML = "../roles/kubespray-defaults/defaults/main/checksums.yml"
@ -171,11 +173,18 @@ def download_hash(only_downloads: [str]) -> None:
}
)
response.raise_for_status()
def valid_version(possible_version: str) -> Optional[Version]:
try:
return Version(possible_version)
except InvalidVersion:
return None
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
{
v for r in repo["releases"]["nodes"]
if not r["isPrerelease"]
and (v := valid_version(r["tagName"])) is not None
}
for repo in response.json()["data"]["with_releases"]
],

Loading…
Cancel
Save