[eks] Refactor script (#224)
Make the script more readable, mostly by: - changing slightly the logic, - using the Product and AutoConfig classes, - removing the use of functions when unnecessary, - a little bit of renaming and documentation. Disabled web.archive.org has also been re-enabled because HTTP retry mechanism has been improved and should handle timeouts a lot better.
This commit is contained in:
@@ -43,19 +43,73 @@
|
||||
"1.25-eks-3": "2023-05-05",
|
||||
"1.24-eks-6": "2023-05-05",
|
||||
"1.23-eks-8": "2023-05-05",
|
||||
"1.22-eks-12": "2023-05-05",
|
||||
"1.21-eks-17": "2023-05-05",
|
||||
"1.20-eks-14": "2023-05-05",
|
||||
"1.26-eks-1": "2023-04-11",
|
||||
"1.25-eks-2": "2023-03-24",
|
||||
"1.24-eks-5": "2023-03-24",
|
||||
"1.23-eks-7": "2023-03-24",
|
||||
"1.22-eks-11": "2023-03-24",
|
||||
"1.21-eks-16": "2023-03-24",
|
||||
"1.25-eks-1": "2023-02-21",
|
||||
"1.24-eks-4": "2023-01-27",
|
||||
"1.23-eks-6": "2023-01-27",
|
||||
"1.22-eks-10": "2023-01-27",
|
||||
"1.21-eks-15": "2023-01-27",
|
||||
"1.24-eks-3": "2022-12-05",
|
||||
"1.23-eks-5": "2022-12-05",
|
||||
"1.22-eks-9": "2022-12-05",
|
||||
"1.21-eks-14": "2022-12-05",
|
||||
"1.20-eks-12": "2022-12-05",
|
||||
"1.24-eks-2": "2022-11-18",
|
||||
"1.23-eks-4": "2022-11-18",
|
||||
"1.22-eks-8": "2022-11-18",
|
||||
"1.21-eks-13": "2022-11-18",
|
||||
"1.20-eks-11": "2022-11-18",
|
||||
"1.24-eks-1": "2022-11-15",
|
||||
"1.23-eks-3": "2022-11-07",
|
||||
"1.22-eks-7": "2022-11-07",
|
||||
"1.21-eks-12": "2022-11-07",
|
||||
"1.20-eks-10": "2022-11-07",
|
||||
"1.21-eks-11": "2022-10-10",
|
||||
"1.23-eks-2": "2022-09-21",
|
||||
"1.23-eks-1": "2022-08-11"
|
||||
"1.22-eks-6": "2022-09-21",
|
||||
"1.20-eks-9": "2022-09-21",
|
||||
"1.22-eks-5": "2022-08-15",
|
||||
"1.21-eks-10": "2022-08-15",
|
||||
"1.20-eks-8": "2022-08-15",
|
||||
"1.19-eks-11": "2022-08-15",
|
||||
"1.23-eks-1": "2022-08-11",
|
||||
"1.22-eks-4": "2022-07-21",
|
||||
"1.21-eks-9": "2022-07-21",
|
||||
"1.20-eks-7": "2022-07-21",
|
||||
"1.22-eks-3": "2022-07-07",
|
||||
"1.21-eks-8": "2022-07-07",
|
||||
"1.22-eks-2": "2022-05-31",
|
||||
"1.21-eks-7": "2022-05-31",
|
||||
"1.20-eks-6": "2022-05-31",
|
||||
"1.19-eks-10": "2022-05-31",
|
||||
"1.21-eks-6": "2022-04-08",
|
||||
"1.20-eks-5": "2022-04-08",
|
||||
"1.19-eks-9": "2022-04-08",
|
||||
"1.22-eks-1": "2022-04-04",
|
||||
"1.20-eks-13": "2022-03-24",
|
||||
"1.21-eks-5": "2022-03-10",
|
||||
"1.20-eks-4": "2022-03-10",
|
||||
"1.19-eks-8": "2022-03-10",
|
||||
"1.21-eks-4": "2021-12-13",
|
||||
"1.21-eks-3": "2021-11-08",
|
||||
"1.20-eks-3": "2021-11-08",
|
||||
"1.19-eks-7": "2021-11-08",
|
||||
"1.21-eks-2": "2021-09-17",
|
||||
"1.19-eks-6": "2021-09-17",
|
||||
"1.20-eks-2": "2021-07-30",
|
||||
"1.21-eks-1": "2021-07-19",
|
||||
"1.19-eks-5": "2021-06-01",
|
||||
"1.20-eks-1": "2021-05-18",
|
||||
"1.19-eks-4": "2021-05-04",
|
||||
"1.19-eks-3": "2021-04-14",
|
||||
"1.19-eks-2": "2021-03-23",
|
||||
"1.19-eks-1": "2021-02-16"
|
||||
}
|
||||
@@ -11,6 +11,7 @@ logging.basicConfig(format=logging.BASIC_FORMAT, level=logging.INFO)
|
||||
# Handle versions having at least 2 digits (ex. 1.2) and at most 4 digits (ex. 1.2.3.4), with an optional leading "v".
|
||||
# Major version must be >= 1.
|
||||
DEFAULT_VERSION_REGEX = r"^v?(?P<major>[1-9]\d*)\.(?P<minor>\d+)(\.(?P<patch>\d+)(\.(?P<tiny>\d+))?)?$"
|
||||
DEFAULT_VERSION_PATTERN = re.compile(DEFAULT_VERSION_REGEX)
|
||||
DEFAULT_TAG_TEMPLATE = "{{major}}{% if minor %}.{{minor}}{% if patch %}.{{patch}}{% if tiny %}.{{tiny}}{%endif%}{%endif%}{%endif%}"
|
||||
|
||||
PRODUCTS_PATH = os.environ.get("PRODUCTS_PATH", "website/products")
|
||||
|
||||
55
src/eks.py
55
src/eks.py
@@ -1,45 +1,40 @@
|
||||
import re
|
||||
from bs4 import BeautifulSoup
|
||||
from common import http
|
||||
from common import dates
|
||||
from common import endoflife
|
||||
|
||||
# Now that AWS no longer publishes docs on GitHub,
|
||||
# we use the Web Archive to still get the older versions
|
||||
# Keep older pages at top of the list
|
||||
"""Fetches EKS versions from AWS docs.
|
||||
Now that AWS no longer publishes docs on GitHub, we use the Web Archive to still get the older versions."""
|
||||
|
||||
URLS = [
|
||||
# 1.19.eks.1
|
||||
# Disabled, too much timed out.
|
||||
# "https://web.archive.org/web/20221007150452/https://docs.aws.amazon.com/eks/latest/userguide/platform-versions.html",
|
||||
"https://web.archive.org/web/20221007150452/https://docs.aws.amazon.com/eks/latest/userguide/platform-versions.html",
|
||||
# + 1.20
|
||||
# Disabled, too much timed out.
|
||||
# "https://web.archive.org/web/20230521061347/https://docs.aws.amazon.com/eks/latest/userguide/platform-versions.html",
|
||||
"https://web.archive.org/web/20230521061347/https://docs.aws.amazon.com/eks/latest/userguide/platform-versions.html",
|
||||
# + latest
|
||||
"https://docs.aws.amazon.com/eks/latest/userguide/platform-versions.html",
|
||||
]
|
||||
|
||||
product = endoflife.Product("eks")
|
||||
print(f"::group::{product.name}")
|
||||
|
||||
def parse_platforms_pages():
|
||||
all_versions = {}
|
||||
print("::group::eks")
|
||||
for url in URLS:
|
||||
response = http.fetch_url(url)
|
||||
soup = BeautifulSoup(response.text, features="html5lib")
|
||||
for tr in soup.select("#main-col-body")[0].findAll("tr"):
|
||||
td = tr.find("td")
|
||||
if td and re.match(endoflife.DEFAULT_VERSION_REGEX, td.text.strip()):
|
||||
data = tr.findAll("td")
|
||||
date = data[-1].text.strip()
|
||||
if len(date) > 0:
|
||||
d = dates.parse_date(date).strftime("%Y-%m-%d")
|
||||
k8s_version = ".".join(data[0].text.strip().split(".")[:-1])
|
||||
eks_version = data[1].text.strip().replace(".", "-")
|
||||
version = f"{k8s_version}-{eks_version}"
|
||||
all_versions[version] = d
|
||||
print(f"{version}: {d}")
|
||||
print("::endgroup::")
|
||||
return all_versions
|
||||
for version_list in http.fetch_urls(URLS):
|
||||
version_list_soup = BeautifulSoup(version_list.text, features="html5lib")
|
||||
for tr in version_list_soup.select("#main-col-body")[0].findAll("tr"):
|
||||
cells = tr.findAll("td")
|
||||
if not cells:
|
||||
continue
|
||||
|
||||
k8s_version = cells[0].text.strip()
|
||||
eks_version = cells[1].text.strip()
|
||||
date_str = cells[-1].text.strip()
|
||||
|
||||
versions = parse_platforms_pages()
|
||||
endoflife.write_releases('eks', versions)
|
||||
k8s_version_match = endoflife.DEFAULT_VERSION_PATTERN.match(k8s_version)
|
||||
if k8s_version_match:
|
||||
date = dates.parse_date(date_str)
|
||||
# K8S patch version is not kept to match versions on https://github.com/aws/eks-distro/tags.
|
||||
version = f"{k8s_version_match.group('major')}.{k8s_version_match.group('minor')}-{eks_version.replace('.', '-')}"
|
||||
product.declare_version(version, date)
|
||||
|
||||
product.write()
|
||||
print("::endgroup::")
|
||||
|
||||
Reference in New Issue
Block a user