Skip to content

Conversation

@kvaps
Copy link
Member

@kvaps kvaps commented Nov 25, 2025

Signed-off-by: Andrei Kvapil kvapss@gmail.com

Summary by CodeRabbit

  • Chores
    • Switched preset handling from a build-time generator to runtime resolution.
    • Removed the automatic preset-generation step from the build/CI flow.
    • CI now skips generation checks on pull requests and runs only for tagged releases.
    • Removed the makefile target that triggered generation.
    • Added a new ignore entry to the repo configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

@gemini-code-assist
Copy link
Contributor

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 modernizes the application's handling of embedded chart files by transitioning from a custom code generation approach to Go's built-in embed package. This change simplifies the build process, reduces external dependencies, and centralizes the logic for managing and accessing preset chart configurations.

Highlights

  • Migration to go:embed: The project now utilizes Go's native embed directive to include chart files directly into the compiled binary, eliminating the need for a separate code generation step.
  • Introduction of charts package: A new charts package has been created to encapsulate the logic for embedding and accessing preset chart files, providing PresetFiles() and AvailablePresets() functions.
  • Removal of code generation script: The tools/generate_presets.go script, previously responsible for generating pkg/generated/presets.go, has been removed.
  • Simplified build process: The Makefile has been updated to remove the generate target, streamlining the build workflow.
  • Refactored preset access: The pkg/commands/init.go file now retrieves preset chart data and available preset names by calling functions from the new charts package, rather than directly accessing generated variables.
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.

@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

Warning

Rate limit exceeded

@kvaps has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 21 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 40158bd and ccd7cb5.

⛔ Files ignored due to path filters (1)
  • pkg/generated/presets.go is excluded by !**/generated/**
📒 Files selected for processing (8)
  • .github/workflows/generate.yml (0 hunks)
  • .github/workflows/release.yml (0 hunks)
  • .gitignore (1 hunks)
  • Makefile (0 hunks)
  • charts/charts.go (1 hunks)
  • main.go (0 hunks)
  • pkg/commands/init.go (5 hunks)
  • tools/generate_presets.go (0 hunks)

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Refactors preset provisioning from a build-time generator to runtime accessors: removes the generator, CI generation workflow, and make/go:generate triggers; adds runtime chart preset functions and updates init logic to call them with error handling.

Changes

Cohort / File(s) Summary
VCS / CI / build config
/.gitignore, /.github/workflows/generate.yml, /.github/workflows/release.yml, /Makefile, /main.go
Added talm to .gitignore; removed generate target from Makefile; removed go:generate directive from main.go; deleted CI workflow .github/workflows/generate.yml; changed .github/workflows/release.yml to no longer trigger on pull_request (only tag push triggers remain).
New runtime preset provider
charts/charts.go
Added charts package file implementing PresetFiles() (map[string]string, error) and AvailablePresets() ([]string, error). Uses embed.FS to walk embedded chart files, skips talm subpaths, replaces Chart.yaml name/version with placeholders via regex, and returns ordered presets (ensuring generic first).
Updated preset consumer
pkg/commands/init.go
Reworked preset handling to call generated.AvailablePresets() and generated.PresetFiles() (both now return errors); adjusted isValidPreset to accept available presets; added error handling and replaced direct variable use with retrieval calls across generation and talm chart update logic.
Removed generator and generated vars
tools/generate_presets.go, pkg/generated/...
Removed the tools/generate_presets.go code generator and deleted the previously generated static variables PresetFiles (map) and AvailablePresets (slice) from pkg/generated (now provided at runtime).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Dev as Developer / CI
    participant Repo as Repository
    participant OldGen as tools/generate_presets.go
    participant GenPkg as pkg/generated (vars)
    participant Init as pkg/commands/init.go
    participant Charts as charts/charts.go

    rect rgb(240,248,255)
    note right of OldGen: OLD FLOW (before)
    Dev->>Repo: push
    Repo->>OldGen: go generate / CI runs generator
    OldGen-->>GenPkg: write PresetFiles & AvailablePresets (static)
    Init->>GenPkg: read variables (compile-time)
    end

    rect rgb(245,255,245)
    note right of Charts: NEW FLOW (after)
    Dev->>Repo: push
    Repo--x OldGen: generator removed
    Init->>Charts: call AvailablePresets() (runtime)
    Charts-->>Init: return []string, error
    Init->>Charts: call PresetFiles() (runtime)
    Charts-->>Init: return map[string]string, error
    Init->>Init: apply presets and update TALM chart with returned data
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas to focus:
    • charts/charts.go: embedded FS traversal, path skipping logic, and regex for Chart.yaml substitution.
    • pkg/commands/init.go: new error paths, updated isValidPreset signature, and consistent use of the returned presetFiles map.
    • CI/build changes: ensure removal of generator and CI workflow aligns with release process and that no consumers expect the generated pkg.

Poem

🐇
I hopped from build to runtime light,
No generator whirl in the night—
Presets now leap when callers call,
Charts unfurl on demand for all. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main objective: replacing code generation with Go's embed feature for handling preset files.

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.

Copy link
Contributor

@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 is a great improvement, replacing a code generation step with go:embed. This simplifies the build process and makes the project easier to maintain. The implementation is solid. I've found a couple of areas for improvement: one is a minor performance optimization in charts/charts.go by avoiding regex compilation in a loop, and the other is a more significant logic refactoring in pkg/commands/init.go to fix some redundancy and bugs in the updateTalmLibraryChart function. Overall, excellent work.

Copy link

@coderabbitai coderabbitai bot left a 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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
pkg/commands/init.go (4)

130-134: Missing error handling for writeToDestination call.

On line 131, the error return from writeToDestination is discarded when writing Chart.yaml files. This means failures are silently ignored.

 			if parts[len(parts)-1] == "Chart.yaml" {
-				writeToDestination([]byte(fmt.Sprintf(content, clusterName, Config.InitOptions.Version)), file, 0o644)
+				err = writeToDestination([]byte(fmt.Sprintf(content, clusterName, Config.InitOptions.Version)), file, 0o644)
 			} else {
 				err = writeToDestination([]byte(content), file, 0o644)
 			}

142-146: Missing error handling for writeToDestination call.

Same issue as above - the error return from line 143 is discarded for talm's Chart.yaml.

 			if parts[len(parts)-1] == "Chart.yaml" {
-				writeToDestination([]byte(fmt.Sprintf(content, "talm", Config.InitOptions.Version)), file, 0o644)
+				err = writeToDestination([]byte(fmt.Sprintf(content, "talm", Config.InitOptions.Version)), file, 0o644)
 			} else {
 				err = writeToDestination([]byte(content), file, 0o644)
 			}

184-198: Duplicate RemoveAll deletes the file just written.

The code writes talm/Chart.yaml on lines 189-193, but then immediately removes the entire talmChartDir again on lines 195-198. This deletes the file that was just written. The second RemoveAll appears to be leftover from refactoring.

Remove the redundant deletion:

 	file := filepath.Join(talmChartDir, "Chart.yaml")
 	err = writeToDestination([]byte(fmt.Sprintf(content, "talm", Config.InitOptions.Version)), file, 0o644)
 	if err != nil {
 		return err
 	}
 
-	// Remove the existing talm chart directory
-	if err := os.RemoveAll(talmChartDir); err != nil {
-		return fmt.Errorf("failed to remove existing talm chart directory: %w", err)
-	}
-
 	for path, content := range presetFiles {

206-210: Missing error handling for writeToDestination call.

Same issue - the error return from line 207 is discarded for Chart.yaml.

 			if parts[len(parts)-1] == "Chart.yaml" {
-				writeToDestination([]byte(fmt.Sprintf(content, "talm", Config.InitOptions.Version)), file, 0o644)
+				err = writeToDestination([]byte(fmt.Sprintf(content, "talm", Config.InitOptions.Version)), file, 0o644)
 			} else {
 				err = writeToDestination([]byte(content), file, 0o644)
 			}
🧹 Nitpick comments (2)
charts/charts.go (2)

43-47: Consider compiling the regex once outside the walk function.

The regex is currently compiled for each Chart.yaml file encountered. Moving it outside the walk function avoids repeated compilation.

+var chartYamlRegex = regexp.MustCompile(`(name|version): \S+`)
+
 // PresetFiles returns a map of file paths to their contents.
 // For Chart.yaml files, name and version are replaced with %s placeholders.
 func PresetFiles() (map[string]string, error) {

Then use chartYamlRegex.ReplaceAllString(content, "$1: %s") inside the function.


73-89: Non-deterministic ordering of presets.

The order of presets (other than generic being first) depends on the filesystem's directory entry order, which may vary. If consistent ordering is desired for user-facing output, consider sorting the presets.

+import "sort"
+
 // ...
 
 	// Put generic first if it exists
+	sort.Strings(presets)
 	if hasGeneric {
 		presets = append([]string{"generic"}, presets...)
 	}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d55f10 and aa32962.

⛔ Files ignored due to path filters (1)
  • pkg/generated/presets.go is excluded by !**/generated/**
📒 Files selected for processing (6)
  • .gitignore (1 hunks)
  • Makefile (0 hunks)
  • charts/charts.go (1 hunks)
  • main.go (0 hunks)
  • pkg/commands/init.go (5 hunks)
  • tools/generate_presets.go (0 hunks)
💤 Files with no reviewable changes (3)
  • Makefile
  • main.go
  • tools/generate_presets.go
🧰 Additional context used
🧬 Code graph analysis (2)
charts/charts.go (1)
pkg/generated/presets.go (2)
  • PresetFiles (7-9)
  • AvailablePresets (13-15)
pkg/commands/init.go (2)
charts/charts.go (2)
  • AvailablePresets (64-97)
  • PresetFiles (16-60)
pkg/generated/presets.go (2)
  • AvailablePresets (13-15)
  • PresetFiles (7-9)
🔇 Additional comments (4)
.gitignore (1)

1-1: LGTM!

The .gitignore entry correctly excludes the talm directory from version control, aligning with the shift to embedded presets.

charts/charts.go (1)

11-12: LGTM!

The all: prefix correctly ensures hidden files (like .helmignore) are included in the embedded filesystem.

pkg/commands/init.go (2)

67-73: LGTM!

Proper error handling for AvailablePresets() and good refactoring to pass the presets list to isValidPreset instead of fetching it again.


230-237: LGTM!

Good refactoring to accept availablePresets as a parameter rather than fetching it internally.

Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps kvaps merged commit d6fa28e into main Nov 25, 2025
2 checks passed
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