Skip to content

bugfix: fix create config kube version key#2964

Merged
ks-ci-bot merged 1 commit intokubesphere:mainfrom
zxs-test:bugfix/fix-kube-version-key
Jan 20, 2026
Merged

bugfix: fix create config kube version key#2964
ks-ci-bot merged 1 commit intokubesphere:mainfrom
zxs-test:bugfix/fix-kube-version-key

Conversation

@zuoxuesong-worker
Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

fix create config kube version key

Which issue(s) this PR fixes:

Fixes #

Special notes for reviewers:

 fix create config kube version key

Does this PR introduced a user-facing change?

fix create config kube version key

Additional documentation, usage docs, etc.:

 fix create config kube version key

@kubesphere-prow kubesphere-prow bot added release-note kind/bug Categorizes issue or PR as related to a bug. labels Jan 20, 2026
@kubesphere-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zuoxuesong-worker

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubesphere-prow kubesphere-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 20, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @zuoxuesong-worker, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a bug in how the Kubernetes version key is handled during the creation of configuration files. The change ensures that the kube_version parameter is correctly nested within a kubernetes object when passed to the configuration template, resolving an issue where the key might have been incorrectly interpreted or missing in the generated configuration.

Highlights

  • Configuration Template Data Structure: Modified the data structure passed to the t.Execute function when generating the configuration file. It now uses a nested map[string]any{"kubernetes": map[string]any{"kube_version": kubeVersion}} instead of a flat map[string]string{"kube_version": kubeVersion}. This ensures the kube_version is correctly nested under a kubernetes key in the template context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@kubesphere-prow kubesphere-prow bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jan 20, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to fix an issue with the kube_version key when generating a default configuration from a template. The change correctly identifies that some templates expect a nested structure (kubernetes.kube_version), but the implementation breaks compatibility with templates that expect a top-level kube_version key. My review includes a critical feedback with a code suggestion to support both structures, ensuring that all default configuration templates can be rendered correctly.

}
data := bytes.NewBuffer(nil)
if err := t.Execute(data, map[string]string{"kube_version": kubeVersion}); err != nil {
if err := t.Execute(data, map[string]any{"kubernetes": map[string]any{"kube_version": kubeVersion}}); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The current change fixes an issue where {{ .kubernetes.kube_version }} would not render correctly in the config templates. However, it removes the top-level kube_version key from the data passed to the template.

Many of the config templates (e.g., builtin/core/defaults/config/v1.33.yaml) and parts of other templates (e.g., line 9 in v1.23.yaml through v1.32.yaml and v1.34.yaml) still use {{ .kube_version }}. This change will cause template execution to fail for those cases.

To fix this without breaking existing templates, you should provide both the top-level kube_version and the nested kubernetes.kube_version in the data map. This ensures both syntaxes are supported.

Suggested change
if err := t.Execute(data, map[string]any{"kubernetes": map[string]any{"kube_version": kubeVersion}}); err != nil {
if err := t.Execute(data, map[string]any{"kube_version": kubeVersion, "kubernetes": map[string]any{"kube_version": kubeVersion}}); err != nil {

@zuoxuesong-worker zuoxuesong-worker force-pushed the bugfix/fix-kube-version-key branch from 7006580 to e0e2419 Compare January 20, 2026 08:45
@kubesphere-prow kubesphere-prow bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 20, 2026
@zuoxuesong-worker zuoxuesong-worker force-pushed the bugfix/fix-kube-version-key branch from e0e2419 to 90cb939 Compare January 20, 2026 08:48
@kubesphere-prow kubesphere-prow bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 20, 2026
bugfix: fix create config kube version key

bugfix: fix create config kube version key

bugfix: fix create config kube version key

Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>
@zuoxuesong-worker zuoxuesong-worker force-pushed the bugfix/fix-kube-version-key branch from 90cb939 to 9003901 Compare January 20, 2026 09:21
@sonarqubecloud
Copy link
Copy Markdown

@redscholar
Copy link
Copy Markdown
Contributor

/lgtm

@kubesphere-prow kubesphere-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jan 20, 2026
@kubesphere-prow
Copy link
Copy Markdown

LGTM label has been added.

DetailsGit tree hash: db7a76d45391c11a2fe823d4135f0612c1241053

@ks-ci-bot ks-ci-bot merged commit fd08c8c into kubesphere:main Jan 20, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants