Align custom scripts with generic scripts (#445)
Align custom scripts with generic scripts, making them configurable. This has a few advantages: - script code is more unified, - no more hard-coded method names in scripts, which is less error prone and make it easier to rename scripts, - no more hard coded product names in scripts, which is less error prone and make it easier to rename products, - less hard-coded URLs and regexes in scripts, which makes auto-configuration more expressive / updatable, Also added method `endoflife.list_configs_from_argv()` so that it is easier to manipulate scripts arguments.
This commit is contained in:
37
src/kuma.py
37
src/kuma.py
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
|
||||
import yaml
|
||||
from common import dates, http, releasedata
|
||||
from common import dates, endoflife, http, releasedata
|
||||
|
||||
"""Fetch version data for Kuma from https://raw.githubusercontent.com/kumahq/kuma/master/versions.yml.
|
||||
"""
|
||||
@@ -10,25 +10,26 @@ RELEASE_FIELD = 'release'
|
||||
RELEASE_DATE_FIELD = 'releaseDate'
|
||||
EOL_FIELD = 'endOfLifeDate'
|
||||
|
||||
with releasedata.ProductData("kuma") as product_data:
|
||||
yml_response = http.fetch_url("https://raw.githubusercontent.com/kumahq/kuma/master/versions.yml")
|
||||
versions_data = yaml.safe_load(yml_response.text)
|
||||
for config in endoflife.list_configs_from_argv():
|
||||
with releasedata.ProductData(config.product) as product_data:
|
||||
yml_response = http.fetch_url(config.url)
|
||||
versions_data = yaml.safe_load(yml_response.text)
|
||||
|
||||
# Iterate through the versions and their associated dates
|
||||
for version_info in versions_data:
|
||||
release_name = version_info[RELEASE_FIELD]
|
||||
if not release_name.endswith('.x'):
|
||||
logging.info(f"skipping release with name {release_name}: does not end with '.x'")
|
||||
continue
|
||||
# Iterate through the versions and their associated dates
|
||||
for version_info in versions_data:
|
||||
release_name = version_info[RELEASE_FIELD]
|
||||
if not release_name.endswith('.x'):
|
||||
logging.info(f"skipping release with name {release_name}: does not end with '.x'")
|
||||
continue
|
||||
|
||||
if RELEASE_DATE_FIELD not in version_info or EOL_FIELD not in version_info:
|
||||
logging.info(f"skipping release with name {release_name}: does not contain {RELEASE_DATE_FIELD} or {EOL_FIELD} fields")
|
||||
continue
|
||||
if RELEASE_DATE_FIELD not in version_info or EOL_FIELD not in version_info:
|
||||
logging.info(f"skipping release with name {release_name}: does not contain {RELEASE_DATE_FIELD} or {EOL_FIELD} fields")
|
||||
continue
|
||||
|
||||
release = product_data.get_release(release_name.replace('.x', ''))
|
||||
release = product_data.get_release(release_name.replace('.x', ''))
|
||||
|
||||
release_date = dates.parse_date(version_info[RELEASE_DATE_FIELD])
|
||||
release.set_field('releaseDate', release_date)
|
||||
release_date = dates.parse_date(version_info[RELEASE_DATE_FIELD])
|
||||
release.set_field('releaseDate', release_date)
|
||||
|
||||
eol = dates.parse_date(version_info[EOL_FIELD])
|
||||
release.set_field('eol', eol)
|
||||
eol = dates.parse_date(version_info[EOL_FIELD])
|
||||
release.set_field('eol', eol)
|
||||
|
||||
Reference in New Issue
Block a user