mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2025-12-13 21:34:40 +03:00
download: cleanup graphQL query
- remove unused parts in the response - clarify variables names
This commit is contained in:
@@ -204,13 +204,13 @@ def download_hash(downloads: {str: {str: Any}}) -> None:
|
|||||||
|
|
||||||
|
|
||||||
releases, tags = map(dict, partition(lambda r: r[1].get('tags', False), downloads.items()))
|
releases, tags = map(dict, partition(lambda r: r[1].get('tags', False), downloads.items()))
|
||||||
ql_params = {
|
repos = {
|
||||||
'repoWithReleases': [r['graphql_id'] for r in releases.values()],
|
'with_releases': [r['graphql_id'] for r in releases.values()],
|
||||||
'repoWithTags': [t['graphql_id'] for t in tags.values()],
|
'with_tags': [t['graphql_id'] for t in tags.values()],
|
||||||
}
|
}
|
||||||
response = s.post("https://api.github.com/graphql",
|
response = s.post("https://api.github.com/graphql",
|
||||||
json={'query': files(__package__).joinpath('list_releases.graphql').read_text(),
|
json={'query': files(__package__).joinpath('list_releases.graphql').read_text(),
|
||||||
'variables': ql_params},
|
'variables': repos},
|
||||||
headers={
|
headers={
|
||||||
"Authorization": f"Bearer {os.environ['API_KEY']}",
|
"Authorization": f"Bearer {os.environ['API_KEY']}",
|
||||||
}
|
}
|
||||||
@@ -228,7 +228,7 @@ def download_hash(downloads: {str: {str: Any}}) -> None:
|
|||||||
return Version(possible_version)
|
return Version(possible_version)
|
||||||
except InvalidVersion:
|
except InvalidVersion:
|
||||||
return None
|
return None
|
||||||
rep = response.json()["data"]
|
repos = response.json()["data"]
|
||||||
github_versions = dict(zip(chain(releases.keys(), tags.keys()),
|
github_versions = dict(zip(chain(releases.keys(), tags.keys()),
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@@ -236,13 +236,13 @@ def download_hash(downloads: {str: {str: Any}}) -> None:
|
|||||||
if not r["isPrerelease"]
|
if not r["isPrerelease"]
|
||||||
and (v := valid_version(r["tagName"])) is not None
|
and (v := valid_version(r["tagName"])) is not None
|
||||||
}
|
}
|
||||||
for repo in rep["with_releases"]
|
for repo in repos["with_releases"]
|
||||||
] +
|
] +
|
||||||
[
|
[
|
||||||
{ v for t in repo["refs"]["nodes"]
|
{ v for t in repo["refs"]["nodes"]
|
||||||
if (v := valid_version(t["name"].removeprefix('release-'))) is not None
|
if (v := valid_version(t["name"].removeprefix('release-'))) is not None
|
||||||
}
|
}
|
||||||
for repo in rep["with_tags"]
|
for repo in repos["with_tags"]
|
||||||
],
|
],
|
||||||
strict=True))
|
strict=True))
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,19 @@
|
|||||||
query($repoWithReleases: [ID!]!, $repoWithTags: [ID!]!) {
|
query($with_releases: [ID!]!, $with_tags: [ID!]!) {
|
||||||
with_releases: nodes(ids: $repoWithReleases) {
|
with_releases: nodes(ids: $with_releases) {
|
||||||
|
|
||||||
... on Repository {
|
... on Repository {
|
||||||
nameWithOwner
|
|
||||||
releases(first: 100) {
|
releases(first: 100) {
|
||||||
nodes {
|
nodes {
|
||||||
tagName
|
tagName
|
||||||
isPrerelease
|
isPrerelease
|
||||||
releaseAssets {
|
|
||||||
totalCount
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
with_tags: nodes(ids: $repoWithTags) {
|
with_tags: nodes(ids: $with_tags) {
|
||||||
|
|
||||||
... on Repository {
|
... on Repository {
|
||||||
nameWithOwner
|
|
||||||
refs(refPrefix: "refs/tags/", last: 25) {
|
refs(refPrefix: "refs/tags/", last: 25) {
|
||||||
nodes {
|
nodes {
|
||||||
name
|
name
|
||||||
|
|||||||
Reference in New Issue
Block a user