bugfix: fix create config kube version key#2964
Conversation
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary of ChangesHello @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 Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
| 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 { |
7006580 to
e0e2419
Compare
e0e2419 to
90cb939
Compare
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>
90cb939 to
9003901
Compare
|
|
/lgtm |
|
LGTM label has been added. DetailsGit tree hash: db7a76d45391c11a2fe823d4135f0612c1241053 |



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:
Does this PR introduced a user-facing change?
Additional documentation, usage docs, etc.: