Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Order Kubernetes releases by publication date #629

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions scripts/validations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from operator import itemgetter
import os
import re
import requests
Expand Down Expand Up @@ -162,20 +163,33 @@ def get_kubernetes_supported_versions():
raise Exception("Failed to fetch Kubernetes releases") from e

releases = response.json()

# Order the releases by publication date
ordered_releases = sorted(releases, key=itemgetter('created_at'), reverse=True)

supported_versions = []
for release in releases:
for release in ordered_releases:
if not release['draft'] and not release['prerelease']:
tag_name = release['tag_name']
if all(x not in tag_name for x in ['alpha', 'beta', 'rc']):
major_minor_version = '.'.join(tag_name.lstrip('v').split('.')[:2])
if major_minor_version not in supported_versions:
supported_versions.append(major_minor_version)
if len(supported_versions) == 3:

# we are taking 5 since smaller versions might have updates after the latest major.minor version
if len(supported_versions) == 5:
break

if not supported_versions:
raise Exception("No supported Kubernetes versions found.")
return supported_versions

# Sort the versions in descending order as strings
sorted_versions = sorted(supported_versions, reverse=True)

# Get the top 3 versions
top_3_versions = sorted_versions[:3]

return top_3_versions

def validate_k8s_supported_versions_in_rego():
# Step 1: Get the latest supported Kubernetes versions
Expand Down
Loading