-
Notifications
You must be signed in to change notification settings - Fork 119
[cozy-lib] Fix malformed retrieval of cozyConfig #1348
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
Conversation
A malformed access to the global context was preventing some helm charts from rendering correctly. Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
WalkthroughThe template now sources cozyConfig from the root context (index . "cozyConfig") instead of a nested context (index . 1 "cozyConfig"). All subsequent logic for computing enabled components and deciding defaultDisableLoadBalancerNodePorts inclusion remains unchanged. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Summary of Changes
Hello @lllamnyp, 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 critical bug where Helm charts were failing to render as expected due to an incorrect method of accessing the "cozyConfig" variable within the "cozy-lib" template. The change rectifies this malformed access by adjusting the index used to retrieve the configuration from the global context. This ensures that "cozyConfig" is loaded properly, allowing affected Helm charts to render and function correctly.
Highlights
- Corrected Configuration Access: The core issue was an incorrect index being used to access the "cozyConfig" variable within the Helm template. This fix ensures that the configuration is retrieved correctly.
- Template Logic Refinement: The change specifically targets the "_network.tpl" file, modifying how "cozyConfig" is accessed to resolve rendering issues for certain Helm charts.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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
-
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. ↩
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.
Code Review
This pull request correctly fixes a bug in the cozy-lib.network.disableLoadBalancerNodePorts
Helm template. The change from index . 1 "cozyConfig"
to index . "cozyConfig"
corrects the method for accessing the cozyConfig
map from the template's context. The original code was attempting to use an invalid integer index on a map, and this fix uses the proper string key, resolving the chart rendering issue. The change is accurate and well-contained.
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/library/cozy-lib/templates/_network.tpl (1)
20-21
: Harden lookup and handle whitespace in bundle-enable listIf $cozyConfig exists but lacks data, index $cozyConfig.data "bundle-enable" can error before default is applied. Also, values like "metallb, robotlb" (notice the space) won’t match has "robotlb". Make the lookup nil-safe and split on comma with optional whitespace.
Apply this diff:
-{{- $enabledComponents := splitList "," ((index $cozyConfig.data "bundle-enable") | default "") }} -{{- not (has "robotlb" $enabledComponents) }} +{{- $data := (index $cozyConfig "data") | default (dict) }} +{{- $raw := (index $data "bundle-enable") | default "" }} +{{- $enabledComponents := regexSplit "\\s*,\\s*" $raw -1 }} +{{- not (has "robotlb" $enabledComponents) }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/library/cozy-lib/templates/_network.tpl
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
🔇 Additional comments (2)
packages/library/cozy-lib/templates/_network.tpl (2)
16-16
: Correctly sourcing cozyConfig from the root contextGood fix. Given the documented invocation pattern (include ... $), retrieving cozyConfig via index . "cozyConfig" is the right context and removes the dependency on the previous tuple-based access.
15-16
: loadCozyConfig mutation verified
- The helper in packages/library/cozy-lib/templates/_cozyconfig.tpl defines
which mutates the second argument—i.e. the original context passed in.{{- $_ := set (index . 1) "cozyConfig" $cozyConfig }}
- In _network.tpl (and in disableLoadBalancerNodePorts), you call
where{{- include "cozy-lib.loadCozyConfig" (list "" .) }}
.
is the root context ($
), and disableLoadBalancerNodePorts itself is invoked with$
as documented.- As a result,
on line 16 will always return the loaded config.$cozyConfig := index . "cozyConfig"
A malformed access to the global context was preventing some helm charts from rendering correctly.
What this PR does
This patch fixes the issue.
Release note
Summary by CodeRabbit