mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2025-12-14 05:45:06 +03:00
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).
This commit is contained in:
@@ -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"]
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user