Skip to content
Snippets Groups Projects
Unverified Commit ae687660 authored by Max Gautier's avatar Max Gautier
Browse files

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).
parent 9f58ba60
No related branches found
No related tags found
No related merge requests found
......@@ -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"]
],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment