Skip to content

Conversation

@kvaps
Copy link
Member

@kvaps kvaps commented Nov 19, 2025

Signed-off-by: Andrei Kvapil [email protected]

Summary by CodeRabbit

  • New Features
    • Chart metadata is now read from local Chart.yaml files
    • HelmRelease objects can specify values files via annotations for enhanced configuration flexibility

@coderabbitai
Copy link

coderabbitai bot commented Nov 19, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The change shifts chart metadata resolution from HelmRelease.chart/ChartRef to reading local Chart.yaml files. Annotation-based ExternalArtifact value file resolution replaces chartRef pathways. Multiple helper functions gain a chartDir parameter, with propagation through call sites and command flow paths.

Changes

Cohort / File(s) Summary
Chart metadata and values resolution refactor
main.go
Updated getChartInfo() to read Chart.yaml from a local chart directory instead of deriving from HelmRelease.chart/ChartRef. Modified mergedValues(), newHistoryEntry(), markSuccess(), renderManifests(), and related helper functions to accept and propagate chartDir parameter. Implemented annotation-based valuesFiles resolution (preferring cozypkg.cozystack.io/values-files annotation with fallback to hr.Spec.Chart.Spec.ValuesFiles). Updated all call sites to pass chartDir ("/." working directory) through the command flow.

Sequence Diagram

sequenceDiagram
    participant Command as Command Flow
    participant GetChart as getChartInfo()
    participant Merged as mergedValues()
    participant Render as renderManifests()
    participant History as newHistoryEntry()
    participant Status as markSuccess()
    participant LocalChart as Local Chart.yaml
    participant HR as HelmRelease Annotations

    Command->>GetChart: chartDir
    GetChart->>LocalChart: Read Chart.yaml
    LocalChart-->>GetChart: Chart name, version
    
    Command->>Merged: chartDir, HelmRelease
    Merged->>HR: Check annotation (values-files)
    HR-->>Merged: Annotation or fallback to spec
    Merged-->>Merged: Parse, trim, load from disk
    
    Command->>Render: chartDir, mergedValues
    Render-->>Command: Rendered manifests
    
    Command->>History: chartDir, status
    History->>GetChart: chartDir
    GetChart->>LocalChart: Extract chart name
    LocalChart-->>History: Chart metadata
    
    Command->>Status: chartDir, success
    Status->>GetChart: chartDir
    GetChart-->>Status: Chart info (fallback to HR name on error)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Function signature changes: Multiple helper functions (getChartInfo, mergedValues, newHistoryEntry, markSuccess, renderManifests) updated to accept chartDir, requiring careful verification of all call sites for correct propagation
  • Annotation-based logic: New conditional resolution path for valuesFiles (annotation-first, spec fallback) introduces logic complexity with multiple branches to trace
  • Error handling fallbacks: newHistoryEntry and markSuccess now fall back to HelmRelease name on getChartInfo errors; verify fallback paths are correct
  • Cross-cutting changes: chartDir threading affects command flow initialization, chart resolution, status updates, and history generation—interconnected changes demand end-to-end validation

Possibly related PRs

  • Support ExternalArtifacts #7: Modifies the same set of Helm release handling functions and chart metadata resolution pathways, suggesting coordinated refactoring of chart information sourcing.

Poem

🐰 From references afar, we now read files near,
Local Chart.yaml whispers secrets clear,
Annotations guide our values with care,
Through chartDir's path, we navigate with flair! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch values-files

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29deec6 and 37d2e85.

📒 Files selected for processing (1)
  • main.go (10 hunks)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @kvaps, 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 introduces a significant enhancement to how Helm valuesFiles are managed by allowing them to be specified via a Kubernetes annotation on HelmRelease objects. This change offers increased flexibility for operators to dynamically configure Helm chart values. Alongside this, the internal logic for extracting chart metadata has been streamlined, shifting from a client-dependent approach to directly parsing Chart.yaml from a local directory, which simplifies the codebase and better integrates with the new annotation-based value file handling.

Highlights

  • Annotation-driven ValuesFiles: HelmRelease objects can now specify valuesFiles using the cozypkg.cozystack.io/values-files annotation, providing a new, flexible way to define value files.
  • ValuesFiles Priority: The newly introduced annotation for valuesFiles takes precedence over any valuesFiles defined directly within the HelmRelease.Spec.Chart.Spec.
  • Simplified Chart Information Retrieval: The getChartInfo function has been refactored to directly read chart metadata (name and version) from a local Chart.yaml file, simplifying its implementation and removing its dependency on the Kubernetes client and HelmRelease object for this specific task.
  • Clarified ExternalArtifact Usage: Comments have been added to the resolveChartRef function to clarify that ExternalArtifact references are now primarily used for chartName and chartVersion resolution, as valuesFiles are handled by the new annotation mechanism.
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.

@kvaps kvaps merged commit a8a9003 into main Nov 19, 2025
1 of 3 checks passed
Copy link

@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 refactors how chart information and valuesFiles are handled. The getChartInfo function is updated to read from a local Chart.yaml, which simplifies the logic and aligns with the tool's local development focus. The most significant change is the introduction of a new annotation, cozypkg.cozystack.io/values-files, to specify values files, replacing the previous method of resolving them via ChartRef. The implementation is mostly solid, but I've identified a bug in the parsing logic for the new annotation that could cause the program to fail. My review includes a suggested fix for this issue.

Comment on lines +396 to +402
if vfStr != "" {
valuesFiles = strings.Split(vfStr, ",")
// Trim whitespace from each value
for i, vf := range valuesFiles {
valuesFiles[i] = strings.TrimSpace(vf)
}
}

Choose a reason for hiding this comment

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

high

The current logic for parsing the cozypkg.cozystack.io/values-files annotation has a bug. If the annotation value contains extra commas or whitespace-only parts (e.g., "file1.yaml, , file2.yaml"), the resulting valuesFiles slice will contain empty strings. This will later cause os.ReadFile to fail when it tries to read a directory path instead of a file.

To fix this, you should filter out empty strings after splitting and trimming the annotation value.

Additionally, it's good practice to define the annotation key "cozypkg.cozystack.io/values-files" as a constant at the package level to improve maintainability and avoid typos.

            if vfStr != "" {
				for _, vf := range strings.Split(vfStr, ",") {
					trimmed := strings.TrimSpace(vf)
					if trimmed != "" {
						valuesFiles = append(valuesFiles, trimmed)
					}
				}
			}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants