-
Notifications
You must be signed in to change notification settings - Fork 57
Update version-support.md via update-kubernetes script #678
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
Monalisa-codes
wants to merge
2
commits into
kr8s-org:main
Choose a base branch
from
Monalisa-codes:changes-in-update-kubernetes-script
base: main
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
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,7 @@ def get_kubernetes_oss_versions(): | |
| "cycle": x["cycle"], | ||
| "latest_version": x["latest"], | ||
| "eol": get_support_date(x), | ||
| "support_source": "OSS Standard Support", | ||
| } | ||
| for x in data | ||
| if has_eol(x) | ||
|
|
@@ -137,6 +138,30 @@ def extend_versions(versions, extended_versions, provider): | |
| f"{provider} support date {extended_version['eol']:%Y-%m-%d}" | ||
| ) | ||
| version["eol"] = extended_version["eol"] | ||
| existing_source = version.get( | ||
| "support_source", "OSS Standard Support" | ||
| ) | ||
|
|
||
| def format_sources(existing, new): | ||
| items = [ | ||
| s.strip().lstrip("-").strip() | ||
| for s in existing.replace("<br>", ",").split(",") | ||
| if s.strip() | ||
| ] | ||
| # Add new provider if not already present | ||
| if new not in items: | ||
| items.append(new) | ||
| return " <br> - " + " <br> - ".join(items) | ||
|
|
||
| if ( | ||
| "Extended Support" in existing_source | ||
| and provider not in existing_source | ||
| ): | ||
| version["support_source"] = format_sources( | ||
| existing_source, provider | ||
| ) | ||
| elif existing_source == "OSS Standard Support": | ||
| version["support_source"] = f"- {provider} Extended Support" | ||
|
Comment on lines
+156
to
+164
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is a little hard to follow, I expect there is a simpler way to implement this. The goal here should be to show which providers are extending the support of each version. |
||
| return versions | ||
|
|
||
|
|
||
|
|
@@ -237,6 +262,39 @@ def update_version_support(versions): | |
| Path("kr8s/_constants.py").write_text(version_support) | ||
|
|
||
|
|
||
| def update_docs_table(versions, doc_path): | ||
| """Generates and inserts a Markdown table of supported versions into a doc file.""" | ||
| print(f"Updating support table in {doc_path}...") | ||
| doc_path = Path(doc_path) | ||
|
|
||
| # 1. Build the Markdown table | ||
| table_lines = [ | ||
| "| Kubernetes Version | Support Until | Source of Support |", | ||
| "|--------------------|---------------|-------------------|", | ||
| ] | ||
| for version in versions: | ||
| eol_date = version["eol"].strftime("%Y-%m-%d") | ||
| source = version.get("support_source", "OSS Standard Support") | ||
| table_lines.append(f"| {version['cycle']} | {eol_date} | {source} |") | ||
|
|
||
| table = "\n".join(table_lines) | ||
|
|
||
| # 2. Read the doc file | ||
| content = doc_path.read_text() | ||
|
|
||
| # 3. Replace content between markers | ||
| new_content = re.sub( | ||
| r"(<!-- BEGIN: VERSION_TABLE -->)(.*?)(<!-- END: VERSION_TABLE -->)", | ||
| f"\\1\n{table}\n\\3", | ||
| content, | ||
| flags=re.DOTALL, | ||
| ) | ||
|
|
||
| # 4. Write updated content | ||
| doc_path.write_text(new_content) | ||
| print("Version support table updated successfully!") | ||
|
|
||
|
|
||
| def main(): | ||
| versions = get_versions() | ||
| print(f"Latest version: {versions[0]['cycle']}") | ||
|
|
@@ -253,6 +311,8 @@ def main(): | |
| update_badges("README.md", versions) | ||
| update_badges("docs/index.md", versions) | ||
| update_version_support(versions) | ||
| update_docs_table(versions, "docs/version-support.md") | ||
|
|
||
| else: | ||
| print("DEBUG env var set, skipping file updates") | ||
|
|
||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function seems out of place. Why is it being defined in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to add this function as a formatter for displaying the service sources names for any version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but defining this as a function within another function is a little strange given that it doesn't require any variables from the scope of the parent function. It would be best to define this at the module level.