-
Notifications
You must be signed in to change notification settings - Fork 11
Add NGINX Gateway Fabric compatibility #3709
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
Open
hunterx-code
wants to merge
5
commits into
pluralsh:master
Choose a base branch
from
hunterx-code:compat/nginx-gateway-fabric
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4b2589d
Add NGINX Gateway Fabric compatibility
hunterx-code 0fcf473
Improve NGINX Gateway Fabric scraper
hunterx-code 27543f3
Fix NGINX Gateway Fabric legacy registry
hunterx-code 25d9df3
Refresh NGINX Gateway Fabric compatibility
hunterx-code a85b66e
Refresh NGINX Gateway Fabric compatibility
hunterx-code File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| icon: https://raw.githubusercontent.com/nginx/nginx-gateway-fabric/main/charts/nginx-gateway-fabric/chart-icon.png | ||
| git_url: https://github.com/nginx/nginx-gateway-fabric | ||
| release_url: https://github.com/nginx/nginx-gateway-fabric/releases/tag/v{vsn} | ||
| helm_repository_url: oci://ghcr.io/nginx/charts/nginx-gateway-fabric | ||
| chart_name: nginx-gateway-fabric | ||
| versions: | ||
| - version: 2.6.7 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 2.6.7 | ||
| images: ['ghcr.io/nginx/nginx-gateway-fabric:2.6.7', 'ghcr.io/nginx/nginx-gateway-fabric/nginx:2.6.7'] | ||
| - version: 2.6.3 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 2.6.3 | ||
| images: ['ghcr.io/nginx/nginx-gateway-fabric:2.6.3', 'ghcr.io/nginx/nginx-gateway-fabric/nginx:2.6.3'] | ||
| - version: 2.5.1 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 2.5.1 | ||
| images: ['ghcr.io/nginx/nginx-gateway-fabric:2.5.1', 'ghcr.io/nginx/nginx-gateway-fabric/nginx:2.5.1'] | ||
| - version: 2.4.2 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31', '1.30', '1.29', '1.28', '1.27', '1.26', | ||
| '1.25'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 2.4.2 | ||
| images: ['ghcr.io/nginx/nginx-gateway-fabric:2.4.2', 'ghcr.io/nginx/nginx-gateway-fabric/nginx:2.4.2'] | ||
| - version: 2.3.0 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31', '1.30', '1.29', '1.28', '1.27', '1.26', | ||
| '1.25'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 2.3.0 | ||
| images: ['ghcr.io/nginx/nginx-gateway-fabric:2.3.0', 'ghcr.io/nginx/nginx-gateway-fabric/nginx:2.3.0'] | ||
| - version: 2.2.2 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31', '1.30', '1.29', '1.28', '1.27', '1.26', | ||
| '1.25'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 2.2.2 | ||
| images: ['ghcr.io/nginx/nginx-gateway-fabric:2.2.2', 'ghcr.io/nginx/nginx-gateway-fabric/nginx:2.2.2'] | ||
| - version: 2.1.4 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31', '1.30', '1.29', '1.28', '1.27', '1.26', | ||
| '1.25'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 2.1.4 | ||
| images: ['ghcr.io/nginx/nginx-gateway-fabric:2.1.4', 'ghcr.io/nginx/nginx-gateway-fabric/nginx:2.1.4'] | ||
| - version: 2.0.2 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31', '1.30', '1.29', '1.28', '1.27', '1.26', | ||
| '1.25'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 2.0.2 | ||
| images: ['ghcr.io/nginx/nginx-gateway-fabric:2.0.2', 'ghcr.io/nginx/nginx-gateway-fabric/nginx:2.0.2'] | ||
| - version: 1.6.2 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31', '1.30', '1.29', '1.28', '1.27', '1.26', | ||
| '1.25'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 1.6.2 | ||
| images: ['ghcr.io/nginx/nginx-gateway-fabric:1.6.2', 'ghcr.io/nginx/nginx-gateway-fabric/nginx:1.6.2'] | ||
| - version: 1.5.1 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31', '1.30', '1.29', '1.28', '1.27', '1.26', | ||
| '1.25'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 1.5.1 | ||
| images: ['ghcr.io/nginxinc/nginx-gateway-fabric:1.5.1', 'ghcr.io/nginxinc/nginx-gateway-fabric/nginx:1.5.1'] | ||
| - version: 1.4.0 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31', '1.30', '1.29', '1.28', '1.27', '1.26', | ||
| '1.25'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 1.4.0 | ||
| images: ['ghcr.io/nginxinc/nginx-gateway-fabric:1.4.0', 'ghcr.io/nginxinc/nginx-gateway-fabric/nginx:1.4.0'] | ||
| - version: 1.3.0 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31', '1.30', '1.29', '1.28', '1.27', '1.26', | ||
| '1.25'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 1.3.0 | ||
| images: ['ghcr.io/nginxinc/nginx-gateway-fabric:1.3.0', 'ghcr.io/nginxinc/nginx-gateway-fabric/nginx:1.3.0'] | ||
| - version: 1.2.0 | ||
| kube: ['1.35', '1.34', '1.33', '1.32', '1.31', '1.30', '1.29', '1.28', '1.27', '1.26', | ||
| '1.25', '1.24', '1.23'] | ||
| requirements: [] | ||
| incompatibilities: [] | ||
| summary: null | ||
| chart_version: 1.2.0 | ||
| images: ['ghcr.io/nginxinc/nginx-gateway-fabric:1.2.0', 'ghcr.io/nginxinc/nginx-gateway-fabric/nginx:1.2.0'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| from collections import OrderedDict | ||
| import re | ||
|
|
||
| import requests | ||
| import yaml | ||
|
|
||
| from utils import ( | ||
| current_kube_version, | ||
| ensure_keys, | ||
| expand_kube_versions, | ||
| print_error, | ||
| print_success, | ||
| read_yaml, | ||
| reduce_versions, | ||
| update_versions_data, | ||
| fetch_page, | ||
| validate_semver, | ||
| write_yaml, | ||
| ) | ||
|
|
||
|
|
||
| APP_NAME = "nginx-gateway-fabric" | ||
| COMPATIBILITY_URL = "https://raw.githubusercontent.com/nginx/documentation/main/content/ngf/overview/technical-specifications.md" | ||
| CHART_VALUES_URL = "https://raw.githubusercontent.com/nginx/nginx-gateway-fabric/v{version}/charts/nginx-gateway-fabric/values.yaml" | ||
| TARGET_FILE = f"../../static/compatibilities/{APP_NAME}.yaml" | ||
|
|
||
|
|
||
| def _decode(content): | ||
| return content.decode("utf-8") if isinstance(content, bytes) else content | ||
|
|
||
|
|
||
| def _clean_cell(cell): | ||
| return re.sub(r"\s+", " ", cell.strip().strip("`").replace("*", "")) | ||
|
|
||
|
|
||
| def _parse_kube_versions(value): | ||
| cleaned = _clean_cell(value).lstrip("v") | ||
| plus_match = re.fullmatch(r"(\d+\.\d+)\+", cleaned) | ||
| if plus_match: | ||
| return expand_kube_versions(plus_match.group(1), current_kube_version()) | ||
|
|
||
| range_match = re.fullmatch(r"(\d+\.\d+)\s*(?:-|–|—)\s*(\d+\.\d+)", cleaned) | ||
| if range_match: | ||
| return expand_kube_versions(range_match.group(1), range_match.group(2)) | ||
|
|
||
| version_match = re.fullmatch(r"\d+\.\d+", cleaned) | ||
| return [cleaned] if version_match else [] | ||
|
|
||
|
|
||
| def _image_from_config(config, fallback_repository, fallback_tag): | ||
| image = config.get("image", {}) if isinstance(config, dict) else {} | ||
| repository = image.get("repository") or fallback_repository | ||
| tag = image.get("tag") or fallback_tag | ||
| return f"{repository}:{tag}" | ||
|
|
||
|
|
||
| def _fallback_image_repositories(version): | ||
| parsed = validate_semver(version) | ||
| org = "nginxinc" if parsed and parsed.major == 1 and parsed.minor < 6 else "nginx" | ||
| repository = f"ghcr.io/{org}/nginx-gateway-fabric" | ||
| return repository, f"{repository}/nginx" | ||
|
|
||
|
|
||
| def _default_images(version): | ||
| control_plane_repository, data_plane_repository = _fallback_image_repositories(version) | ||
| fallbacks = [ | ||
| f"{control_plane_repository}:{version}", | ||
| f"{data_plane_repository}:{version}", | ||
| ] | ||
| try: | ||
| response = requests.get(CHART_VALUES_URL.format(version=version), timeout=10) | ||
| except requests.RequestException: | ||
| return fallbacks | ||
| if response.status_code != 200: | ||
| return fallbacks | ||
|
|
||
| try: | ||
| values = yaml.safe_load(response.text) or {} | ||
| except yaml.YAMLError as exc: | ||
| print_error(f"Failed to parse NGINX Gateway Fabric chart values: {exc}") | ||
| return fallbacks | ||
|
|
||
| control_plane = _image_from_config( | ||
| values.get("nginxGateway", {}), | ||
| control_plane_repository, | ||
| version, | ||
| ) | ||
| data_plane = _image_from_config( | ||
| values.get("nginx", {}), | ||
| data_plane_repository, | ||
| version, | ||
| ) | ||
| return [control_plane, data_plane] | ||
|
|
||
|
|
||
| def _write_compatibility_info(filepath, new_versions): | ||
| data = read_yaml(filepath) or {} | ||
| update_versions_data(data, [ensure_keys(version) for version in new_versions]) | ||
| data["versions"] = reduce_versions(data["versions"]) | ||
| if write_yaml(filepath, data): | ||
| print_success(f"Updated compatibility info table: {filepath}") | ||
| else: | ||
| print_error(f"Failed to update compatibility info for {filepath}") | ||
|
|
||
|
|
||
| def extract_table_data(content): | ||
| rows = [] | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| in_table = False | ||
|
|
||
| for line in _decode(content).splitlines(): | ||
| stripped = line.strip() | ||
| if stripped.startswith("| NGINX Gateway Fabric | Gateway API | Kubernetes |"): | ||
| in_table = True | ||
| continue | ||
| if in_table and not stripped.startswith("|"): | ||
| break | ||
| if not in_table or set(stripped.replace("|", "").strip()) <= {"-"}: | ||
| continue | ||
|
|
||
| columns = [_clean_cell(column) for column in stripped.strip("|").split("|")] | ||
| if len(columns) < 3: | ||
| continue | ||
| app_version = columns[0].lstrip("v") | ||
| if app_version.lower() == "edge": | ||
| continue | ||
| version = validate_semver(app_version) | ||
| if not version: | ||
| continue | ||
|
|
||
| ver = str(version) | ||
| kube_versions = _parse_kube_versions(columns[2]) | ||
| if not kube_versions: | ||
| print_error( | ||
| f"Could not parse Kubernetes versions for NGINX Gateway Fabric {ver}: {columns[2]}" | ||
| ) | ||
| continue | ||
|
|
||
| rows.append( | ||
| OrderedDict( | ||
| [ | ||
| ("version", ver), | ||
| ("kube", kube_versions), | ||
| ("chart_version", ver), | ||
| ("images", _default_images(ver)), | ||
| ("requirements", []), | ||
| ("incompatibilities", []), | ||
| ] | ||
| ) | ||
| ) | ||
|
|
||
| return rows | ||
|
|
||
|
|
||
| def scrape(): | ||
| page_content = fetch_page(COMPATIBILITY_URL) | ||
| if not page_content: | ||
| return | ||
|
|
||
| rows = extract_table_data(page_content) | ||
| if not rows: | ||
| print_error("No NGINX Gateway Fabric compatibility rows found.") | ||
| return | ||
|
|
||
| _write_compatibility_info(TARGET_FILE, rows) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.