[google-kubernetes-engine] Normalize script (#464)
The script used to parse different channel for historical (forgotten) reasons. This is the only script that works that way, and release data is not supposed to be consumed by other clients than endoflife.date. So aligning this script for all the other scripts. In case other channel data is useful for someone, it would be preferable to create multiple products so that the data is available through our official API.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -33,13 +33,16 @@ class AutoConfig:
|
|||||||
def first_match(self, version: str) -> re.Match | None:
|
def first_match(self, version: str) -> re.Match | None:
|
||||||
for exclude_pattern in self.exclude_version_patterns:
|
for exclude_pattern in self.exclude_version_patterns:
|
||||||
if exclude_pattern.match(version):
|
if exclude_pattern.match(version):
|
||||||
|
logging.debug(f"Excluding '{version}' as it matches exclude pattern '{exclude_pattern.pattern}'")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
for include_pattern in self.include_version_patterns:
|
for include_pattern in self.include_version_patterns:
|
||||||
match = include_pattern.match(version)
|
match = include_pattern.match(version)
|
||||||
if match:
|
if match:
|
||||||
|
logging.debug(f"Returning '{version}' as it matches include pattern '{include_pattern.pattern}'")
|
||||||
return match
|
return match
|
||||||
|
|
||||||
|
logging.debug(f"{version} does not match any include or exclude patterns")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def is_excluded(self, version: str) -> bool:
|
def is_excluded(self, version: str) -> bool:
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
import re
|
import logging
|
||||||
|
|
||||||
from common import dates, http
|
from common import dates, http
|
||||||
from common.releasedata import ProductData, config_from_argv
|
from common.releasedata import ProductData, config_from_argv
|
||||||
|
|
||||||
# https://regex101.com/r/zPxBqT/1
|
"""Fetches versions from Google Kubernetes Engine release notes.
|
||||||
VERSION_PATTERN = re.compile(r"\d.\d+\.\d+-gke\.\d+")
|
|
||||||
URL_BY_PRODUCT = {
|
|
||||||
"google-kubernetes-engine": "https://cloud.google.com/kubernetes-engine/docs/release-notes-nochannel",
|
|
||||||
"google-kubernetes-engine-stable": "https://cloud.google.com/kubernetes-engine/docs/release-notes-stable",
|
|
||||||
"google-kubernetes-engine-regular": "https://cloud.google.com/kubernetes-engine/docs/release-notes-regular",
|
|
||||||
"google-kubernetes-engine-rapid": "https://cloud.google.com/kubernetes-engine/docs/release-notes-rapid",
|
|
||||||
}
|
|
||||||
|
|
||||||
config = config_from_argv() # multiple JSON produced for historical reasons
|
This script does not work for versions prior to March 29, 2021, as the release note format was different before that date.
|
||||||
for product_name, url in URL_BY_PRODUCT.items():
|
"""
|
||||||
with ProductData(product_name) as product_data:
|
|
||||||
html = http.fetch_html(url)
|
|
||||||
|
|
||||||
for section in html.find_all('section', class_='releases'):
|
config = config_from_argv()
|
||||||
for h2 in section.find_all('h2'): # h2 contains the date
|
with ProductData(config.product) as product_data:
|
||||||
date = dates.parse_date(h2.get('data-text'))
|
html = http.fetch_html(config.url)
|
||||||
|
regex = config.data.get('regex')
|
||||||
|
|
||||||
next_div = h2.find_next('div') # The div next to the h2 contains the notes about changes made on that date
|
for section in html.find_all('section', class_='releases'):
|
||||||
for li in next_div.find_all('li'):
|
for h2 in section.find_all('h2'): # h2 contains the date
|
||||||
if "versions are now available" in li.text:
|
date = dates.parse_date(h2.get('data-text'))
|
||||||
for version in VERSION_PATTERN.findall(li.find('ul').text):
|
|
||||||
product_data.declare_version(version, date)
|
for li in h2.find_next('div').find_all('li'):
|
||||||
|
if "versions are now available" not in li.text:
|
||||||
|
logging.debug(f"Skipping {li.text}: does not contain new versions")
|
||||||
|
continue
|
||||||
|
|
||||||
|
for sub_li in li.find_all('li', recursive=True):
|
||||||
|
match = config.first_match(sub_li.text.strip())
|
||||||
|
if match:
|
||||||
|
product_data.declare_version(config.render(match), date)
|
||||||
|
|||||||
Reference in New Issue
Block a user